vue2.5+基础

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue2.5+基础相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html> <html> <head> <title>vue</title> <!-- <script src="./vue.js"></script> --> <script src="http://cdn.staticfile.org/vue/2.6.10/vue.common.dev.js"></script> </head> <body> <div id="root"> msg num <div v-html="wocao"></div> <div v-text="wocao"></div> <div v-on:click="handleClick">content</div> <div v-bind:title="title">title</div> <input type="text" :value="neirong"> <!-- v-bind:可简写为: --> <input type="text" v-model:value="neirong"> <div>neirong</div> <br> 姓:<input v-model="firstName"> 名:<input v-model="lastName"> <div>firstName lastName</div> <div>fullName</div> <div>count</div> <!-- v-show和v-if:前者是隐藏/显示,后者是销毁/创建,显然v-show更省资源(浏览器资源也是资源!) --> <div v-if="show">show-hidden</div> <div v-show="show">show-hidden</div> <button v-on:click="toggleFunc">toggle</button> <button @click="toggleFunc">toggle</button> <!-- 最好有个:key来标记,以增加性能(:key不能重复) --> <ul> <li v-for="(item, index) of list1" :key="index">item</li> </ul> <input v-model="inputValue"/> <button @click="addTextFunc">提交</button> <ul> <li v-for="(item, index) of list2" :key="index">item</li> </ul> <div v-html="doChange"></div> </div> <script> var app = new Vue( el: "#root", data: msg: "hello world", num: "1", wocao: "<b>wo cao a</b>", content: "content: hello", title: "啊哈哈title", neirong: "这里是内容", firstName: "", lastName: "", count: 0, show: true, list1: [1, 2, 3], list2: [], doChange: ‘<h1>哈哈哈</h1>‘ , computed: fullName: function() return this.firstName + " " + this.lastName , watch: fullName: function() this.count++ , methods: handleClick: function() alert("转换为大写"); this.content = "CONTENT: HELLO" , toggleFunc: function() /*if (this.show == false) this.show = true else this.show = false */ this.show = !this.show , addTextFunc: function() this.list2.push(this.inputValue) this.inputValue = "" ); setTimeout(function() app.$data.doChange = "<span style=‘color:red‘><h1>嘿嘿嘿</h1></span>" , 1000) </script> </body> </html>

以上是关于vue2.5+基础的主要内容,如果未能解决你的问题,请参考以下文章

Vue2.5开发去哪儿网App 从零基础入门到实战项目

Vue2.5开发去哪儿网App 从零基础入门到实战项目

Vue2.5开发去哪儿网App 从零基础入门到实战项目

Vue2.5开发去哪儿网App

Vue2.5入门教程

Vue2.5 Web App 项目搭建 (TypeScript版)