摘要: vue2中ref操作原生Dom元素 vue3中实时更新DOM数据需要导入 基本数据类型 import {ref} from 'vue' 数据定义需要包裹ref 定义的数据vue将他放入了一个对象之中,所以在获取这个值时需要 如name.value这样获取。 <template> <h1>一个人的信息 阅读全文
posted @ 2022-01-27 16:57 ajaXJson 阅读(2925) 评论(0) 推荐(0) 编辑
摘要: // 源数据 let person = { name: '张三', age: 18 } //#region // 模拟Vue2中实现响应式 // let p = {} // Object.defineProperties(p, 'name', { // configurable: true, // 阅读全文
posted @ 2022-01-27 16:57 ajaXJson 阅读(45) 评论(0) 推荐(0) 编辑
摘要: Vue2可读取vue3的内容,而vue3不可读取vue2的 <script>//import {h} from 'vue'export default{name:'App', setup(){ //数据 let name='张三' let age = 18 //方法 function sayHell 阅读全文
posted @ 2022-01-27 16:56 ajaXJson 阅读(326) 评论(0) 推荐(0) 编辑
摘要: vue3中的export default中不需要分开data,methods等,统一写在setup中,并且取值时,不需要用this.name <template> <h1>一个人的信息</h1> <h2>姓名:{{name}}</h2> <h2>年龄:{{age}}</h2> <button @cl 阅读全文
posted @ 2022-01-27 16:56 ajaXJson 阅读(260) 评论(0) 推荐(0) 编辑
摘要: <template> <!-- Vue3组件中的模板结构可以没有跟标签> //<div> <img alt="Vue logo" src="./assets/logo.png"> //</div></template> 阅读全文
posted @ 2022-01-27 16:54 ajaXJson 阅读(632) 评论(0) 推荐(0) 编辑
摘要: Vue3 //引入的不再是Vue构造函数了,引入的是一个名为creatApp的工厂函数import {creatApp} from 'vue'import App from './App.vue'//创建应用实例对象 app(类似于之前Vue2中的vm,但app比vm更“轻”)const app = 阅读全文
posted @ 2022-01-27 16:53 ajaXJson 阅读(331) 评论(0) 推荐(0) 编辑