vue-day25--v-pre指令

发布时间 2023-07-16 21:31:35作者: 雪落无痕1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>v-pre指令</title>
<script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="root">
<!--
v-pre指令
1.跳过其所在节点的编译过程
2.可利用它跳过:没有使用指令语法,没有使用插值语法的节点 会加速编译过程

-->
<h2 v-pre>vue 其实很简单</h2>
<h2 v-once>初始化的n值{{n}}</h2>
<h1>当前n的值{{n}}</h1>
<button @click="n++">点我加上n+1</button>
</div>

<script type="text/javascript">
new Vue({
el: "#root", //el用于指定当前vue实例为那个容器服务,但通常为css选择器字符串
data: {
n: 1,
},
});
</script>
</body>
</html>