02.Vue2.x Vue模版语法

文章目录

Vue模版语法

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>模版语法</title>
    <script type="text/javascript" src="../js/vue.js"></script>
  </head>
  <body>
    <!-- 
        Vue模版语法有2大类
        1.插值语法:
            功能:用于解析标签体内容
            写法:{{xxx}},xxx会作为表达式去解析,且可以自动读取到data中的属性
        2.指令语法:
            功能:用于解析标签(包括:标签属性、标签内容、绑定事件......)
            举例:v-bind:href="xxxx" 或:href='xxx'
            备注:Vue中有很多的指令都可以简写
     -->
    <div id="root">
      <h2>插值语法</h2>
      <h4>你好{{msg}}</h4>
      <h4>你好{{msg.toUpperCase()}}</h4>
      <hr />
      <h2>指令语法</h2>
      <!-- v-bind: 可以简写为 : -->
      <a :href="url">点我去学习</a>
      <a href="http://www.baidu.com" :x="msg">点我去学习</a>
    </div>
    <script>
      new Vue({
        el: "#root",
        data: {
          msg: "atguigu",
          url: "https://www.baidu.com",
        },
      });
    </script>
  </body>
</html>
相关推荐
Aric_Jones2 小时前
JavaScript 从入门到精通:完整语法指南
开发语言·javascript·ecmascript
岱宗夫up2 小时前
FastAPI入门(上篇):快速构建高性能Python Web API
开发语言·前端·python·fastapi
紫陌涵光3 小时前
112. 路径总和
java·前端·算法
漠月瑾-西安3 小时前
CVE-2025-55182漏洞解析:你的React项目安全吗?
前端·安全·react.js
No丶slovenly3 小时前
flutter笔记-输入框
前端·笔记·flutter
国产化创客3 小时前
ESP32+Web实现智能气象站
前端·物联网·智能家居·智能硬件
coderYYY4 小时前
VSCode终端启动报错
前端·ide·vscode·npm·编辑器
西门吹-禅4 小时前
文本搜索node js--meilisearch
开发语言·javascript·ecmascript
tod1135 小时前
Redis 数据类型与 C++ 客户端实践指南(redis-plus-plus)
前端·c++·redis·bootstrap·html
Sylvia33.5 小时前
火星数据:棒球数据API
java·前端·人工智能