<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>指令-内置指令</title>
<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="example">
<p>xin{{message}}xin</p>
<p v-text="message">-----</p>
<p v-html="message"></p>
<p ref="content">luckxinxin</p>
<button @click="hint">点击提示内容</button>
</div>
<script type="text/javascript">
new Vue({
el: '#example',
data: {
message: '<a href="https://blog.csdn.net/LuckXinXin">主页</a>'
},
methods: {
hint () {
alert(this.$refs.content.innerHTML)
}
}
})
</script>
</body>
</html>
运行结果:
大家可以自己尝试运行一下