我的需求如下:1、input內輸入值時,input控制元件上方顯示值跟著改變;2、點擊“獲取資料”實作改變input控制元件和input控制元件上方顯示的值。以下代碼只實作了需求1,為何不能實作需求2?新人請大神們指教!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue 測驗實體 - 菜鳥教程(runoob.com)</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="app">
<p>{{ message }}</p>
<input v-model="message">
<input type="button" @click="handleGetDevice" value="https://bbs.csdn.net/topics/獲取資料">
</div>
<script>
new Vue({
el: '#app',
data: {
message: 'Runoob!'
},
methods:{
handleGetDevice:function(){
message = "Test";
}
}
})
</script>
</body>
</html>
uj5u.com熱心網友回復:
this.message = "Test";轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/83080.html
標籤:JavaScript
上一篇:求助,Python問題
下一篇:js代碼滑動到頁面固定位置
