首页 技术 正文
技术 2022年11月12日
0 收藏 908 点赞 3,333 浏览 1410 个字

1.领导安排明天给同事们科普下vue

2.简单写了两个小例子

3.话不多说直接上代码

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.active {
width: 100px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<!--这是我们的View-->
<div id="app">
{{ message }}
</div>
<hr />
<div id="model">
<input type="text" v-model="text" />
<span>{{text}}</span>
</div>
<hr />
<div id="_class">
<div v-bind:class="{ 'active' : isTrue }">1</div>
<div v-bind:class="{ 'active' : getClass }">1</div>
</div>
<hr />
<div id="_function">
<span>{{art}}</span>
<input type="button" v-on:click="getClick" />
<select v-on:change="getChange">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<hr />
<div id="_ifAndFor">
<template v-for="(son, index) in father">
<span v-if="index % 2 == 0">{{son}}</span>
<span v-else-if="index % 3 == 0" style="background-color: green;">{{son}}</span>
</template>
</div>
</hr>
</body>
<script src="js/vue.js"></script>
<script>
// 这是我们的Model
var exampleData = {
message: 'Hello World!'
} // 创建一个 Vue 实例或 "ViewModel"
// 它连接 View 与 Model
new Vue({
el: '#app',
data: exampleData
})
new Vue({
el: '#model',
data: {
text: ""
}
})
new Vue({
el: '#_class',
data: {
isTrue: false
},
methods: {
getClass: function () {
return !this.isTrue;
}
}
})
new Vue({
el: '#_function',
data: {
art: ""
},
methods: {
getClick: function () {
this.art = "梵高";
},
getChange: function () {
this.art = "达文西";
}
}
})
new Vue({
el: "#_ifAndFor",
data: {
father: []
},
methods: { },
mounted: function () {
for (var i = 0; i < 10; i++) {
this.father.push('son' + i);
}
}
})
</script>
</html>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,085
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,560
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,409
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,182
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,819
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,902