<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue 测试实例</title>
<style>
.class1 {
background: #444;
color: eee;
}
</style>
<script src=https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
<div id=app">
<input type="text" v-model="textss">
<!--<button @click="sub">提交</button>-->
</div>
<script>
var vm = new Vue({
el: '#app',data: {
textss:"" 监听属性
watch:{
textss(old_data,new_data){
if (old_data.search("逼") != -1 || old_data.search("你") != -1){
var text = old_data.slice(0,-1);
var text_c = text + "*"
this.textss = text_c
}
},
},})
</script>
</body>
</html>