1. 程式人生 > >vue 實現 點擊取消監控內容是否發生修改 若修改提示 是否需要保存

vue 實現 點擊取消監控內容是否發生修改 若修改提示 是否需要保存

.text class ext 1.0 lib scrip can script query

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue對象變化測試</title>
    <script src="http://cdn.bootcss.com/vue/1.0.28/vue.js"></script>
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.min.js"></script>
    <style>
        .active{
            color:#f00;
        }
    
</style> </head> <body> <div id="page"> <!-- tap按鈕 --> <div> <button :class="{active:current==1}" @click = "current = 1">按鈕01</button> <button :class="{active:current==2}" @click = "current = 2">按鈕02</button> </div> <!-- 內容1 --> <div v-if
="current == 1"> <input type="text" v-model="msg.name"> <input type="text" v-model="msg.age"> <input type="text" v-model="msg.sex"> </div> <!-- 內容2 --> <div v-if="current == 2"> <input type="text" v-model="text.name"> <input type="text" v-model="text.age"> <input type="text" v-model="text.sex"> </div> <div :do
="jc" :do2="jc02">{{jc|json}}---{{jc02|json}}</div> <button @click="cancel">取消</button> </div> <script> var vm = new Vue({ el:‘#page‘, data:{ msg:{}, text:{}, current:1 }, methods:{ cancel:function(){ if(this.jc || this.jc02){ alert("方案基準內容已修改,是否需要保存?") } } }, computed:{ ‘jc‘:function(){ if($.trim(this.msg.name) || $.trim(this.msg.age) || $.trim(this.msg.sex)){ return this.msg; } }, ‘jc02‘:function(){ if($.trim(this.text.name) || $.trim(this.text.age) || $.trim(this.text.sex)){ return this.text; } } } }); </script> </body> </html>

vue 實現 點擊取消監控內容是否發生修改 若修改提示 是否需要保存