77 lines
1.8 KiB
HTML
77 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Document</title>
|
||
</head>
|
||
|
||
<body>
|
||
<div class="app">
|
||
<h2 ref="test">我是h2</h2>
|
||
<h1>{{ msg | shenglh }}</h1>
|
||
<h3>{{ test2 }}</h3>
|
||
</div>
|
||
</body>
|
||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
|
||
<script>
|
||
var mix = {
|
||
data(){
|
||
return {
|
||
page:0,
|
||
totalPage:10,
|
||
}
|
||
},
|
||
methods:{
|
||
bottom(){
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
var vm = new Vue({
|
||
el:'.app',
|
||
mixins:[mix],
|
||
data:{
|
||
msg:'hahahhahahhahahhahahhahahhahahhahah'
|
||
},
|
||
watch:{
|
||
msg(newVal,oldVal){
|
||
console.log(newVal,oldVal);
|
||
}
|
||
},
|
||
beforeCreate(){
|
||
},
|
||
created(){
|
||
console.log(this.page);
|
||
console.log("created");
|
||
},
|
||
mounted(){
|
||
console.log("mounted");
|
||
},
|
||
filters:{
|
||
//()中会自动收到一个value值,为14行中自动调用shenglh方法,
|
||
//把msg中的值传到这个方法中用()中的字母随便填
|
||
//return返回的值会再次覆盖msg
|
||
shenglh(val){
|
||
return val.substring(0,3)+"..."
|
||
}
|
||
},
|
||
methods:{
|
||
test2(){
|
||
return "你好"
|
||
}
|
||
},
|
||
//computed用于大量数据的计算
|
||
computed:{
|
||
test(){
|
||
return "test"
|
||
}
|
||
},
|
||
})
|
||
</script>
|
||
|
||
</html> |