最简单的非模块化的vue笔记
来源:互联网 发布:西瓜影音mac 编辑:程序博客网 时间:2024/06/05 21:17
用了vue,vue-router,axios,会持续更新
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>demo</title> <link rel="stylesheet" href="../lib/bower_components/bootstrap/css/bootstrap.min.css"> <script src="../vue/vue.js"></script> <script src="../vue/vue-router.js"></script> <script src="../vue/axios.min.js"></script></head><body><div class="container mt-2" id="app"> <router-link to="/home" class="btn btn-danger">Home</router-link> <router-link to="/phone" class="btn btn-primary">Phone</router-link> <router-link to="/student" class="btn btn-dark">Students</router-link> <router-link to="/request" class="btn btn-info">HTTP</router-link> <router-view></router-view></div><div id="tempate"> <!--home template--> <template id="home"> <div> <h1>Home</h1> <div class="card card-block"> <h4 class="card-title">Home Message</h4> <div class="card-text"><p>{{msg}}</p></div> <div class="form-inline"> <input type="text" class="form-control" id="new_home_msg" v-model="new_home_msg"> <button class="btn btn-link" @click="change_msg">更改</button> </div> </div> </div> </template> <!--phone template--> <template id="phone"> <div> <h1>Phone</h1> <div class="card card-block"> <h4 class="card-title">{{name}}</h4> <ul> <li v-for="brand in brands">{{brand}}</li> </ul> <div class="form-inline"> <input type="text" class="form-control" v-model="input_brand_value"> <button class="btn btn-outline-primary" @click="add_brand">添加品牌</button> </div> </div> </div> </template> <!--student temlpate--> <template id="student"> <div> <h1>Student</h1> <div class="card card-block"> <h4 class="card-title">{{name}}</h4> <ul> <li v-for="(student,index) in students">{{student}} <span @click="del(index)" style="cursor: pointer">×</span></button></li> </ul> <div class="form-inline"> <input type="text" class="form-control" v-model="input_student_value"> <button class="btn btn-primary" @click="add_student">添加学生</button> </div> </div> </div> </template> <!--request temlpate--> <template id="request"> <div> <h1>Request</h1> <div class="card card-block"> <h4 class="card-title">{{name}}</h4> <div class="card-text"> {{content}} </div> <div class="card-footer"> <button class="btn-dark btn" @click="send">发送请求</button> </div> </div> </div> </template></div></body></html><script> var Home = Vue.component('home', { template: '#home', data: function () { return { msg: 'hello world', new_home_msg: '' } }, methods:{ change_msg:function () { this.msg = this.new_home_msg } } }); var Phone = Vue.component('phone', { template: '#phone', data: function () { return { name: 'phone', brands: ['Samsung', 'Apple', 'Nokia'], input_brand_value:'' } }, methods:{ add_brand:function () { this.brands.push(this.input_brand_value) } } }); var Student = Vue.component('student', { template: '#student', data: function () { return { name: 'student', students: ['xiaoming', 'zhangsan', 'lisi'], input_student_value:'' } }, methods:{ add_student:function () { this.students.push(this.input_student_value) }, del:function (index) { this.students.splice(index,1) } } }); var Request = Vue.component('request',{ template:'#request', data:function () { return { name:'Request', content:'' } }, methods:{ send:function () { let self = this; axios.get('http://httpbin.org/get').then(function (response) { self.content = JSON.stringify(response.data.headers) }) } } }); var routes = [ {path:'/',redirect:'/home'}, {path: '/home', component: Home}, {path: '/phone', component: Phone}, {path: '/student', component: Student}, {path:'/request',component:Request} ]; const router = new VueRouter({ routes }); new Vue({ router, el: '#app' })</script>
阅读全文
0 0
- 最简单的非模块化的vue笔记
- vue最简单的例子
- 最简单的vue上传图片
- Vue初体验(一),最简单的Vue示例
- 笔记&讨论:什么是模块化开发以及最基本的应用
- vue-router2.0的最简单的例子
- [笔记]最简单的神经网络
- 最简单的sublime text 3安装vue插件
- 最简单的VUE pc端项目打包
- 基于vue-cli的vue项目之vuex的使用1---------最简单的vuex模板
- 教你用最简单的JS代码,写出自己的模块化开发
- vue的简单语法
- Vue的简单指令
- vue-简单的todolist
- 大小非骇人听闻成本最简单的演示!!
- vue.js 学习笔记 制作简单的todo list
- 初学者的vue笔记
- vue的笔记
- 关于使用bat执行jar包
- linux 技巧:使用 screen 管理你的远程会话
- hdu 6206 Apple(Java大数)
- 第四章 INI配置
- Cocos Creator 前言
- 最简单的非模块化的vue笔记
- 005_Tomcat环境配置与Tomcat项目部署
- laravel的request里的get和input区别
- centOS 安装tomcat
- 构造函数调用顺序
- 生命游戏Java实现
- springMVC与app对接
- Android开发你需要知道的注解(Annotation)
- React Native手势识别