<div id="app">
<input type="text" class="form-control" v-model="text">
<button class="btn btn-primary mt-1" v-on:click="reverseText">反轉字串</button>
<div class="mt-3">
    {{ newText }}
</div>
</div>
var app = new Vue({
    el: '#app',
    data: {
    text: '',
    newText: ''
    },
    methods: {
    reverseText: function(){
            console.log('點我', this.name);
            this.newText = this.text.split('').reverse().join('');
    }
    }
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js