“VUE 本地应用”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
 
(未显示同一用户的29个中间版本)
第6行: 第6行:
 
3.列表循环,表单元素绑定
 
3.列表循环,表单元素绑定
  
[[Vue v-text 指令|v-text]]
+
=== 内容绑定,事件绑定 ===
 +
[[Vue v-text 指令]]
  
=== v-text ===
+
[[Vue v-html 指令]]
https://www.bilibili.com/video/BV12J411m7MG/?p=7
 
  
 +
[[Vue v-on 指令]]
  
设置标签的文本值(textContent)<syntaxhighlight lang="html">
+
[[Vue 计数器]]
<div id="app">
 
<h2 v-text="message"></h2>
 
</div>
 
  
var app = new Vue({
+
=== 显示切换,属性绑定 ===
  el:"#app",
+
[[Vue v-show 指令]]
  data:{
 
    message:"hello world"
 
  }
 
})
 
</syntaxhighlight>
 
上面的示例会替换 h2 标签内的全部内容
 
  
有时候我们希望只对标签内的部分文本内容进行替换:<syntaxhighlight lang="html">
+
[[Vue v-if 指令]]
<div id="app">
 
<h2>深圳{{ message }}</h2>
 
</div>
 
  
var app = new Vue({
+
[[Vue v-bind 指令]]
  el:"#app",
 
  data:{
 
    message:"hello world"
 
  }
 
})
 
</syntaxhighlight>上面示例中这种写法就是官方推荐的 <u>插值表达式</u>,可以只对标签内部的部分文本内容进行替换。
 
  
字符串拼接<syntaxhighlight lang="html">
+
[[Vue 图片切换]]
<div id="app">
+
=== 列表循环,表单元素绑定 ===
<h2 v-text="message+'!'"></h2>
+
[[Vue v-for 指令]]
<h2>深圳{{ message + "!" }}</h2>
 
</div>
 
  
var app = new Vue({
+
[[Vue v-on 补充]]
  el:"#app",
+
 
  data:{
+
[[Vue v-model 指令]]
    message:"hello world"
+
 
  }
+
=== 小黑记事本 ===
})
+
[[Vue 小黑记事本 介绍]]
</syntaxhighlight><syntaxhighlight lang="html">
+
 
<!DOCTYPE html>
+
[[Vue 小黑记事本 新增]]
<html lang="en">
+
 
<head>
+
[[Vue 小黑记事本 删除]]
    <meta charset="UTF-8">
+
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
[[Vue 小黑记事本 统计]]
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+
 
    <title>v-text指令</title>
+
[[Vue 小黑记事本 清空]]
</head>
+
 
<body>
+
[[Vue 小黑记事本 隐藏]]
  <div id="app">
+
 
    <h2 v-text="message">北京</h2>
+
https://github.com/jihch/vue_learning/tree/master/%E5%B0%8F%E9%BB%91%E8%AE%B0%E4%BA%8B%E6%9C%AC
    <h2 v-text="message+'!'">北京</h2>
 
    <h2 v-text="info">北京</h2>
 
    <h2 v-text="info+'!'">北京</h2>
 
    <h2>{{ message }}北京</h2>
 
    <h2>{{ message + '!' }}北京</h2>
 
  </div>
 
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
 
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
 
<script>
 
    var app = new Vue({
 
        el: "#app",
 
        data:{
 
            message:"hello world!!!",
 
            info:"前端测试"
 
        }
 
    })
 
</script>
 
</body>
 
</html>
 
</syntaxhighlight>
 

2023年8月11日 (五) 01:28的最新版本