close
 
<div id="app">
<input type="text" class="form-control" value="456" v-model="text">
<button class="btn btn-primary mt-1" v-on:click="reverseText">反轉字串</button>
<div class="mt-3">
{{ newText }}
</div>
</div>

//v-model ="text" 對應到value 取data裡的text的值

//只能用在這三個屬性 input select textarea

//v-on:click 對應到methods的reserseText的函數

<script>
var app = new Vue({
el: '#app',
data: {
text: '123',
newText: ''
},
// 請在此撰寫 JavaScript
methods:{
reverseText:function(){
this.newText = this.text.split('').reverse().join('')
 
}
 
}
});
</script>
arrow
arrow
    文章標籤
    Vue
    全站熱搜

    code學習筆記中心 發表在 痞客邦 留言(0) 人氣()