diff --git "a/\346\236\227\351\270\277\351\221\253/note2021-5-29-01.md" "b/\346\236\227\351\270\277\351\221\253/note2021-5-29-01.md" new file mode 100644 index 0000000000000000000000000000000000000000..48948dae966d11c119122ba3419f769e55b7736a --- /dev/null +++ "b/\346\236\227\351\270\277\351\221\253/note2021-5-29-01.md" @@ -0,0 +1,268 @@ +# Vue的第四次课 + +## 模板语法 + +### 文本 + +通过使用 v-once 指令,你也能执行一次性地插值,当数据改变时,插值处的内容不会更新。但请留心这会影响到该节点上的其它数据绑定 + +例子: + +
+ Message:{{msg}} + 这个将不会改变: {{ msg }} +
+ + + + + +结果:当你插入app.msg='游海水哦'是 + 是这样: + + Message:游海水哦 这个将不会改变: 6060 + + +### 原始 HTML +双大括号会将数据解释为普通文本,而非 HTML 代码。为了输出真正的 HTML,你需要使用 v-html + +
+

Using mustaches: {{ rawHtml }}

+

Using v-html directive:

+
+ + + +输出是这样的: + + Using mustaches:

我的世界

+ + Using v-html directive: + + 我的世界 + + +### Attribute + +Mustache 语法不能作用在 HTML attribute 上,遇到这种情况应该使用 v-bind: + + div v-bind:id="dynamicId"> + +对于布尔 attribute (它们只要存在就意味着值为 true),v-bind 工作起来略有不同,在这个例子中: + +
+ + +
+ + + + +如果 isButtonDisabled 的值是 null、undefined 或 false,则 disabled attribute 甚至不会被包含在渲染出来的