根据api说,input框可以使用方法focus()主动聚焦
参见:http://weex.apache.org/cn/ref...,Methods一节
按照上面的说明和官方给出的参考例子写了以下主要代码
<template>
<div>
<div><input ref="input1" class="input" slot="value" type="number" placeholder="请输入数值" v-model="input1" /></div>
<div>
<text class="button" value="Focus" type="primary" @click="focusInput"></text>
</div>
<div>
<text class="button" value="Blur" type="primary" @click="blurInput"></text>
</div>
</div>
</template>
<script>
export default {
methods:{
focusInput(){
this.$refs["input1"].focus();
console.log("focusInput()");
},
blurInput() {
this.$refs["input1"].blur();
console.log("blurInput()");
},
}
}
</script>
问题:focus()的确调出了键盘,但是在键盘上输入字符input框中都没有反应,是不是还缺少了什么。我感觉focus都聚焦了,那输入光标应该定位到指定的ref中去了吧?那为什么input中没有收到键盘中的内容呢?
运行环境ios 11.2.6
weex确实还有很多坑,你弄一个双向绑定,看能不能输出input1里的值,如果有,那就输入进去了,是渲染问题。。。