》》vue
- <!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的更多相关文章
- 《《我是一只IT小小鸟》》读后感
接触IT也已经半年了,在这半年我没有充足的时间去了解IT这个行业,在大学生职业规划课程上,老师推荐了<<我是一只IT小小鸟>>这本书,我才发现IT这个行业并不是想象的那么无趣, ...
- 【图文详细教程】maven3安装配置+eclipse离线安装maven3插件《《唯一成功的教程~~~2018-01-09》》
环境搭建前提: 1.电脑上已经安装了1.7以及以上版本的JDK(因为我提供的maven版本是最新的3.3.9的,要求最低JDK1.7) 2.配置好了ecplise并且能正常启动 第一步:下载maven ...
- jsp---》》》新闻发布系统的项目跟踪+++++++文件上传
先来一个分层架构图: WeebRoot目录下的页面: 现在,此项目以实现登录,注销,新闻列表,编辑主题>>>> 先来登录部分的关键代码 index.jsp中的代码 userIn ...
- 读《《图解TCP-IP》》有感
读<<图解TCP/IP>>有感 TCP/IP 近期几天读完<<图解TCP/IP>>,收获蛮多,记得上学时读stevens的<<TCP/IP具 ...
- heavy dark--读《《暗时间》》
本书名为<<暗时间>>,个人觉得是一个非常好的名字:1.迷茫的大学生有多少的业余时间,但又浪费多少的业余时间,浪费的这莫多时间就如同人在黑夜中一样,大脑是在休息的状态.这是第一 ...
- hadoop 》》 django 简单操作hdfs 语句
>> from django.shortcuts import render # Create your views here. from hdfs.client import Clien ...
- 实体类在Windows程序中的高级应用--------------------》》心境是一种境界。
一.事务 我们在大家学到这,或多或少对事务都有一些理解了.今天的我也对事务有了更深一层的理解对我来说,我想与大家一起分享一下. 解析: 1.ADO.NET提供了事务处理功能 2.C#中开启事务 3.在 ...
- eclipse更改workspace中出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java----问题》》
第一步:那是因为在项目中没有告诉它应该在哪个tomcat中运行,右击项目名称----->build path-->configure path---->library------ ...
- PHP两种基础的算法:冒泡、快速排序法》》》望能够帮助到大家
首先扯个淡@@@@@@@@@ 算法是程序的核心,一个程序的好坏关键是这个程序算法的优劣. 冒泡排序法 原理:在要排序的一组数中,对当前还未排好的序列,从前往后对相邻的两个数依次进行比较和调整,让较大的 ...
随机推荐
- 初入servlet:Allocate exception for servlet
老板,来一碗错误垫垫肚子! 如果以下几个错误都符合,估计就是这个原因了. 页面报错如下: java.lang.NoClassDefFoundError:IllegalName: firstDemo/T ...
- gbdt的面试要点总结-上篇
1.简介 gbdt全称梯度下降树,在传统机器学习算法里面是对真实分布拟合的最好的几种算法之一,在前几年深度学习还没有大行其道之前,gbdt在各种竞赛是大放异彩.原因大概有几个,一是效果确实挺不错.二是 ...
- kafka学习笔记1:测试环境搭建
最近因为架构中引入了kafka,一些之前在代码中通过RPC调用强耦合但是适合异步处理的内容可以用kafka重构一下. 考虑从头学一下kafka了解其特性和使用场景. 环境选择 首先是测试环境的搭建,平 ...
- bzoj1001(对偶图最短路)
显然是个最大流问题. 边数达到了10^6级别,显然用dinic算法会TLE 对于一个平面图来说,当然用对偶图的最短路来求最小割(最大流) SPFA转移的时候注意判断边界情况 应该要开longlong才 ...
- js规范
js规范 Array 和 Object 直接量 为了避免这些歧义, 我们应该使用更易读的直接量来声明. var a = [x1, x2, x3]; var a2 = [x1, x2]; var a3 ...
- java.io.File类操作
一.java.io.File类 String path="E:/222/aaa";//路径 String path1="aaa.txt"; File file= ...
- mysql多个TimeStamp设置(转)
原文地址:http://www.cnblogs.com/yjf512/archive/2012/11/02/2751058.html timestamp设置默认值是Default CURRENT_TI ...
- 创建mysql快捷登录方式
1.先找到mysql的bin目录,将Mysql.exe发送快捷方式到桌面,到这里还没有完成. 2.然后右键选择属性,将目标后面添加上 -uroot -p 我的完整目标如下: D:\install\my ...
- 基于Spring开发的一个BIO-RPC框架(对新人很友好)
PART1:先来整体看下项目的构成 其中bio-rpc-core就是所谓的rpc框架 bio-rpc-example-client即所谓的服务调用方(你的项目中想要调用服务的地方) bio-rpc-e ...
- TCP:传输控制协议
概述: 书中采用了8章来介绍TCP,可见其重要性.TCP是一种面向连接的.可靠的字节流服务,也就是说两方要交换数据必须先建立一个连接. TCP的信息单位称为segment.TCP对字节流的内容不作任何 ...