内置指令 ref和v-cloak
<!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>
<style>
/* {{}}数据未编译时隐藏 */
[v-cloak] {
display: none;
}
</style>
</head>
<body>
<div id="app">
<p ref="content">奋发图强</p>
<button @click="hint">提示</button>
<!-- <p>{{msg}}</p> -->
<!-- 防止闪现,与[v-cloak] {display: none;}合用 -->
<p v-cloak>{{msg}}</p>
</div>
<script src="./js/vue.js"></script>
<script>
alert("--");
new Vue({
el:'#app',
data:{
msg:'天王盖地虎'
},
methods: {
hint(){
alert(this.$refs.content.textContent)
}
}
})
</script>
</body>
</html>