首页 > 其他分享 >vue3学习笔记(一)

vue3学习笔记(一)

时间:2022-11-19 11:23:00浏览次数:49  
标签:Vue const text return 笔记 学习 vue3 createApp message

helloworld

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>ECharts</title>
    <!-- 方法有用 -->
    <!-- <script src="https://unpkg.com/vue@next"></script> -->
    <!-- 方法不生效 Vue未定义 -->
    <!-- <script src="./vue.esm-browser.js" type="module"></script> -->
    <!-- 方法有用 -->
    <script src="./vue.global.js"></script>
  </head>
  <body>
    <div id="counter">Counter: {{ counter }}</div>
    <div id="bind-attribute">
      <span v-bind:title="message">
        鼠标悬停几秒钟查看此处动态绑定的提示信息!
      </span>
    </div>
    <div id="event-handling">
      <p>{{ message }}</p>
      <button v-on:click="reverseMessage">反转 Message</button>
    </div>
    <div id="two-way-binding">
      <p>{{ message }}</p>
      <input v-model="message" />
    </div>
    <div id="conditional-rendering">
      <span v-if="seen">现在你看到我了</span>
    </div>
    <div id="list-rendering">
      <ol>
        <li v-for="todo in todos">{{ todo.text }}</li>
      </ol>
    </div>
    <div id="components-app" class="demo">
      <ol>
        <todo-item
          v-for="item in groceryList"
          v-bind:todo="item"
          v-bind:key="item.id"
        ></todo-item>
      </ol>
    </div>

    <script>
      const Counter = {
        data() {
          return {
            counter: 0,
          };
        },
        mounted() {
          setInterval(() => {
            this.counter++;
          }, 1000);
        },
      };
      Vue.createApp(Counter).mount("#counter");

      const AttributeBinding = {
        data() {
          return {
            message: "You loaded this page on " + new Date().toLocaleString(),
          };
        },
      };
      Vue.createApp(AttributeBinding).mount("#bind-attribute");

      const EventHandling = {
        data() {
          return {
            message: "Hello Vue.js!",
          };
        },
        methods: {
          reverseMessage() {
            this.message = this.message.split("").reverse().join("");
          },
        },
      };
      Vue.createApp(EventHandling).mount("#event-handling");

      const TwoWayBinding = {
        data() {
          return {
            message: "Hello Vue!",
          };
        },
      };
      Vue.createApp(TwoWayBinding).mount("#two-way-binding");

      const ConditionalRendering = {
        data() {
          return {
            seen: true,
          };
        },
      };
      Vue.createApp(ConditionalRendering).mount("#conditional-rendering");

      const ListRendering = {
        data() {
          return {
            todos: [
              { text: "Learn JavaScript" },
              { text: "Learn Vue" },
              { text: "Build something awesome" },
            ],
          };
        },
      };
      Vue.createApp(ListRendering).mount("#list-rendering");

      const ComponentsApp = {
        data() {
          return {
            groceryList: [
              { id: 0, text: "Vegetables" },
              { id: 1, text: "Cheese" },
              { id: 2, text: "Whatever else humans are supposed to eat" },
            ],
          };
        },
      };
      const app = Vue.createApp(ComponentsApp);
      app.component("todo-item", {
        props: ["todo"],
        template: `<li>{{ todo.text }}</li>`,
      });
      app.mount("#components-app");
    </script>
  </body>
</html>

  

标签:Vue,const,text,return,笔记,学习,vue3,createApp,message
From: https://www.cnblogs.com/caroline2016/p/16905694.html

相关文章

  • vue3学习笔记(二)
    应用&组件实例//应用实例constapp=Vue.createApp({data(){return{count:4}}})//组件实例constvm=app.mount('#app')console.log(vm.count......
  • 20201317 LYX 14周学习总结
    MySQL数据库简介MySQL是一个关系型数据库管理系统,是最流行的关系型数据库管理系统之一。在WEB应用方面,MySQL是最好的RDBMS(RelationalDatabaseManagementSystem,关......
  • SICP 笔记
    SICP笔记记录学习《算机的程序的构造和解释》的笔记。环境配置SICP里面使用的语言是一种LISP的变体Scheme。使用DrRacket作为IDE来进行试验,DrRacket有针对S......
  • JavaScript_对象_Global与DOM简单学习
    JavaScript_对象_GlobalGlobal:全局对象1.特点:全局对象,这个Global中封装的方法不需要对象就可以直接调用。方法名();2.方法......
  • RabbitMQ学习笔记(三)
    三利用RabbitMQ高级特性,完善项目的可靠性3.1如何保证消息的可靠性3.1.1发送方需要使用RabbitMQ发送端确认机制,确认消息成功发送到RabbitMQ并被处理需要使用RabbitM......
  • vue3-cookies
    安装npminstallvue3-cookies--savemain.jsimport{createApp}from'vue'importAppfrom'./App.vue'importrouterfrom'./router'importstorefrom'./store......
  • Golang学习之路6-goroutine并发
    @目录前言一、goroutine用法二、goroutine循环三、goroutine提前退出四、goroutine双向管道五、goroutine单向管道六、监听管道如下图,可以看到当我们监听到有写入数据时会......
  • 11.18日学习记录
    2022-11-1813:41:421.TOMCAT的配置tomcat的配置搞了一个上午,还让别人帮了忙,主要是因为tomcat位置放的不好。貌似放在桌面不行,改放在了D盘下,终于解决了之前tomcat启动成......
  • Day2学习:dos的常用指令
     day2学习:dos的常用指令打开方式同时按下win键+r打开运行窗,然后输入cmd,回车也可以在同时按下win+x,或者"开始"菜单上右键,在弹出菜单上选择"命令行提示符"或"命令提......
  • day2学习:dos的常用指令
    day2学习:dos的常用指令打开方式同时按下win键+r打开运行窗,然后输入cmd,回车也可以在同时按下win+x,或者"开始"菜单上右键,在弹出菜单上选择"命令行提示符"或"命令提示......