鍍金池/ 問(wèn)答/Android  HTML/ weex 的 input 組件中的blur和focus函數(shù)無(wú)法調(diào)用?

weex 的 input 組件中的blur和focus函數(shù)無(wú)法調(diào)用?

問(wèn)題

無(wú)法調(diào)用weex的input組件中的blur和focus 函數(shù)。 但我調(diào)用input的blur(focus)函數(shù)時(shí),鍵盤并沒(méi)有被收起,此時(shí)查看Android studio 打印的日志提示一下錯(cuò)誤

12-01 16:13:30.791 32201-32214/com.example.zhangshijie.myapplication E/jsengine:  ReportException :undefined:5: TypeError: Object [object Object] has no method 'blur'
12-01 16:13:30.802 32201-32214/com.example.zhangshijie.myapplication E/jsengine:  ReportException : TypeError: Object [object Object] has no method 'blur'
                                                                                     at t.default.methods.click (eval at Jt ((weex):4:2004), <anonymous>:5:632)
                                                                                     at Object.n [as fn] ((weex):3:3068)
                                                                                     at null.<anonymous> ((weex):3:10683)
                                                                                     at L.Object.assign.fireEvent ((weex):2:29647)
                                                                                     at G.Object.assign.fireEvent ((weex):3:886)
                                                                                     at (weex):4:488
                                                                                     at Array.forEach (native)
                                                                                     at Object.Ft [as receiveTasks] ((weex):4:384)
                                                                                     at Object.M.tu.(anonymous function) [as callJS] ((weex):1:8334)
                                                                                     at global.(anonymous function) ((weex):7:1148)
12-01 16:13:30.802 32201-32214/com.example.zhangshijie.myapplication E/weex: reportJSException >>>> instanceId:1, exception function:callJS, exception:TypeError: Object [object Object] has no method 'blur'

下面是我的.vue 文件內(nèi)容

<template>
  <div @click="click" class="bounds">
      <input ref = "inputMessage" class= "input" type="text" value="測(cè)試數(shù)據(jù)"></input>
  </div>
</template>

<style scoped>

.input {
    top: 100;
    width: 600;
    left: 50;
    height: 100;
    background-color: red
}
.bounds {
    position: absolute;
    top: 0;
    left: 0;
    width: 750;
    background-color: green
}
</style>


<script>
export default {
    methods: {
        click: function(e) {
            this.$refs.inputMessage.blur()
            // console.log('this.refs', this.refs)
        }
    }
}
</script>
回答
編輯回答
空白格

試試把ref="inputMessage"改成ref="'inputMessage'"或者通過(guò)this.$refs['insputMessage'].blur()去調(diào)用

2017年2月19日 08:45