|
分享:
uniapp中获取input框中的value值的方法, 使用v-model 与 ref 结合实现 代码如下: template <template>
<view class="content">
<view>
<input v-model="comment" class="uni-input" focus placeholder="自动获得焦点" />
<view @click="AddComment">评论</view>
</view>
</view>
</template>
script代码: <script>
import {
ref,
getCurrentInstance,
onMounted,
} from 'vue'
export default {
setup() {
const comment = ref(null);
const {
proxy , ctx
} = getCurrentInstance();
onMounted(() => {
console.log(comment.value);
})
const AddComment = ()=>{
console.log("评论:",comment.value);
}
return {
comment,
AddComment
}
}
}
</script> |
|
|