菜鸟教程小白 发表于 2022-12-11 20:43:38

ios - NativeScript - 如何在 iOS 中获取 TextView 的插入符号位置


                                            <p><p>我正在使用 NativeScript-Vue,但在查找 iOS 中 <code>TextView</code> 的插入符号位置时遇到问题</p>

<pre><code>&lt;StackLayout&gt;
    &lt;TextView ref=&#34;input&#34; editable=true @loaded=&#34;getView&#34;/&gt;
&lt;/StackLayout&gt;

...

getView(args) {
    console.log(args.object.ios)      // return {}
    console.log(this.$refs.input.ios) // return {}
}

...
</code></pre>

<p> <a href="https://discourse.nativescript.org/t/getting-cursor-position-of-textview-in-ios/5931" rel="noreferrer noopener nofollow">https://discourse.nativescript.org/t/getting-cursor-position-of-textview-in-ios/5931</a> </p>

<p>我已经阅读了上面的解决方案,但似乎只支持 TypeScript?</p>

<p>我从 <code>this.$refs.input.nativeView.ios</code> 得到的总是 <code>{}</code>(空)</p>

<p>有人知道我错过了什么吗?或者欢迎任何可用的方法!干杯</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>你必须只使用 <code>this.$refs.input.nativeView.ios</code>,它可能会打印空对象,因为它是一个原生组件。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - NativeScript - 如何在 iOS 中获取 TextView 的插入符号位置,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/53001269/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/53001269/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - NativeScript - 如何在 iOS 中获取 TextView 的插入符号位置