<!DOCTYPE html>
<html> <head>
<meta charset="utf-8" />
<title></title>
<style>
.active {
color: red;
} .text-success {
color: #009966;
font-size: 20px;
} .fontWeight {
font-weight: bold;
}
</style>
</head> <body>
<div id="list">
<ul>
<div v-bind:class="[fontWeight,textSuccess]">欢迎品尝</div>
<input type="text" v-model="moonstuffing" maxlength="5" placeholder="请输入您喜欢的月饼馅" />
<div v-bind:class="classObject">中秋节月饼馅</div>
<li v-for="item in mooncake">{{item}}</li> </ul>
<div v-bind:style="obj">花好月圆夜</div>
<my-component v-bind:class="textSuccess" v-bind:message="txt"></my-component>
<!--自定义UI组件--> <user-input v-if="ok" :message="user.loginType" :changevalue="changevaluefn" :values="username" :types="user.textType" :placeholdertext="user.placeText" key="username"></user-input>
<user-input v-else :message="user.loginType" :changevalue="changevaluefn" :values="useremail" :types="user.textType" :placeholdertext="user.placeText" key="useremail"></user-input> <button @click="change">点击切换</button> <hr /> <!--<template> 元素当做包装元素-->
<template v-if="qiehuan">
<label>Username</label>
<input placeholder="Enter your username" key="username-input">
</template> <template v-else>
<label>Email</label>
<input placeholder="Enter your email address" key="email-input">
</template> <button @click="tab">点击切换(使用包装元素)</button> <hr /> <div v-show="ok">
哈哈我显示了
</div> <!-- v-for v-if 结合使用-->
<h1> v-for v-if 结合使用</h1>
<ul>
<li v-for = "item in money" v-if="item.price <= 40">{{item.txt}}</li> </ul> </div>
</body>
<script src="js/vue.js"></script> <script type="text/javascript">
Vue.component('user-input', {
template: '<div><label>{{message}}</label><input :value="values" @input="changevalue" @onpropertychange="changevalue" :type="types" :placeholder="placeholdertext"></div>',
props: ["message", "types", "placeholdertext","values","changevalue"], }) Vue.component('my-component', {
template: '<p class="foo bar">{{message}}</p>',
props: ["message"]
}) var moon = new Vue({
el: "#list",
data: {
ok:true,
qiehuan:true,
isActive: true,
isSuccess: true,
moonstuffing: '',
mooncake: ["蛋黄", "五仁", "豆沙", "莲蓉"],
fontWeight: "fontWeight",
textSuccess: "text-success",
txt: "哈哈",
activeColor: "red",
fontSize: 60,
obj: {
color: "red",
fontSize: "60px"
},
user: {
loginType: "username",
textType: "email",
placeText: "请输入用户名"
},
username:'用户名',
useremail:'邮箱',
money:[
{price: 10,txt:"10元"},
{price: 20,txt:"20元"},
{price: 30,txt:"30元"},
{price: 40,txt:"40元"},
{price: 50,txt:"50元"},
{price: 60,txt:"60元"},
{price: 70,txt:"70元"},
{price: 80,txt:"80元"}
] },
methods: { change: function() {//点击按钮切换 if(this.ok) {
this.ok = false;//控制组件显示隐藏 this.user = {
loginType: "email",
textType: "email",
placeText: "请输入邮箱"
} } else { this.ok = true;//控制组件显示隐藏 this.user = {
loginType: "username",
textType: "text",
placeText: "请输入用户名"
} } },
changevaluefn:function(e){//监听值变化
var e = e || window.event;
var target = e.target || e.srcElement; if(this.ok) {
this.username = target.value //接收用户名
} else {
this.useremail = target.value//接收邮箱 }
},
tab:function() {//点击按钮切换 if(this.qiehuan) {
this.qiehuan = false; } else { this.qiehuan = true;//控制组件显示隐藏 } }
},
watch: { //监听数据发送改变
moonstuffing: function(newValue, oldValue) { //监听属性
console.log(oldValue)
if(newValue != '') {
moon.mooncake.push(newValue)
moon.isActive = true;
} else {
moon.isActive = false;
}
}
}, computed: {
classObject: function() {
return {
active: this.isActive,
'text-success': this.isSuccess
}
}
}
})
</script> </html>

》》vue的更多相关文章

  1. 《《我是一只IT小小鸟》》读后感

    接触IT也已经半年了,在这半年我没有充足的时间去了解IT这个行业,在大学生职业规划课程上,老师推荐了<<我是一只IT小小鸟>>这本书,我才发现IT这个行业并不是想象的那么无趣, ...

  2. 【图文详细教程】maven3安装配置+eclipse离线安装maven3插件《《唯一成功的教程~~~2018-01-09》》

    环境搭建前提: 1.电脑上已经安装了1.7以及以上版本的JDK(因为我提供的maven版本是最新的3.3.9的,要求最低JDK1.7) 2.配置好了ecplise并且能正常启动 第一步:下载maven ...

  3. jsp---》》》新闻发布系统的项目跟踪+++++++文件上传

    先来一个分层架构图: WeebRoot目录下的页面: 现在,此项目以实现登录,注销,新闻列表,编辑主题>>>> 先来登录部分的关键代码 index.jsp中的代码 userIn ...

  4. 读《《图解TCP-IP》》有感

    读<<图解TCP/IP>>有感 TCP/IP 近期几天读完<<图解TCP/IP>>,收获蛮多,记得上学时读stevens的<<TCP/IP具 ...

  5. heavy dark--读《《暗时间》》

    本书名为<<暗时间>>,个人觉得是一个非常好的名字:1.迷茫的大学生有多少的业余时间,但又浪费多少的业余时间,浪费的这莫多时间就如同人在黑夜中一样,大脑是在休息的状态.这是第一 ...

  6. hadoop 》》 django 简单操作hdfs 语句

    >> from django.shortcuts import render # Create your views here. from hdfs.client import Clien ...

  7. 实体类在Windows程序中的高级应用--------------------》》心境是一种境界。

    一.事务 我们在大家学到这,或多或少对事务都有一些理解了.今天的我也对事务有了更深一层的理解对我来说,我想与大家一起分享一下. 解析: 1.ADO.NET提供了事务处理功能 2.C#中开启事务 3.在 ...

  8. eclipse更改workspace中出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java----问题》》

    第一步:那是因为在项目中没有告诉它应该在哪个tomcat中运行,右击项目名称----->build path-->configure   path---->library------ ...

  9. PHP两种基础的算法:冒泡、快速排序法》》》望能够帮助到大家

    首先扯个淡@@@@@@@@@ 算法是程序的核心,一个程序的好坏关键是这个程序算法的优劣. 冒泡排序法 原理:在要排序的一组数中,对当前还未排好的序列,从前往后对相邻的两个数依次进行比较和调整,让较大的 ...

随机推荐

  1. jquery.editable-select 可编辑下拉框之获取select值和input值

    使用jquery.editable-select可以实现可编辑下拉框的功能,但需要先导入jquery.js,jquery.editable-select.css,jquery.editable-sel ...

  2. win10提示管理员已阻止你运行此应用,如何强制运行

      方法/步骤     这里以自己遇到的一个软件为例,下图就是禁止的图画:   在开始菜单中输入"cmd",然后以管理员身份运行:   按住"shift"键,同 ...

  3. spa(单页应用)中,使用history模式时,微信长按识别二维码在ios下失效的问题

    spa(单页应用,vue)中,使用history模式时,微信长按识别二维码在ios下失效的问题. 触发条件: spa单页应用: 路由模式 history 从其他页面跳转到带有微信二维码识别的页面(不是 ...

  4. Tinyhttpd精读解析

    首先,本人刚刚开始开源代码精读,写的不对的地方,大家轻拍,一起进步.本文是对Tinyhttpd的一次精读,大家每天都在用着http服务,很多人也一直活跃在上层,使用IIS.Apache等,大家是否想看 ...

  5. 实现基于LVS负载均衡集群的电商网站架构

    背景 上一期我们搭建了小米网站,随着业务的发展,网站的访问量越来越大,网站访问量已经从原来的1000QPS,变为3000QPS,网站已经不堪重负,响应缓慢,面对此场景,单纯靠单台LNMP的架构已经无法 ...

  6. 前端基于react,后端基于.net core2.0的开发之路(2) 开发环境的配置,注意事项,后端数据初始化

    前端环境配置 项目介绍文章:前端基于react,后端基于.net core2.0的开发之路(1) 介绍 1.VSCode安装 下载地址:https://code.visualstudio.com/Do ...

  7. Linux修改date

    与cn校时 ntpdate cn.pool.ntp.org 设置时区 TZ='Asia/Shanghai'; export TZ 刷新生效 source ~/.bashrc vi /etc/profi ...

  8. java 内部类和闭包

    内部类(inner class) public class Outer{ private String name; class Inner{ public String getOuterName(){ ...

  9. [转载] Kafka+Storm+HDFS整合实践

    转载自http://www.tuicool.com/articles/NzyqAn 在基于Hadoop平台的很多应用场景中,我们需要对数据进行离线和实时分析,离线分析可以很容易地借助于Hive来实现统 ...

  10. HTML的用法

    今天学习了HTMIL,标签.这个东西吧,没什么很难的,就是得多练多打.今天的一些个人心得: 标签:成对存在的名称 标签注意:1.标签名放在<> 2.标签成对存在的 3.结束标签有斜杠/ 例 ...