vue 组件开发
1.新建路由:router-->index.js,修改成下面的代码
import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index/index'
Vue.use(Router)
export default new Router({
mode:'history',
routes: [
{
path: '/',
name: 'index',
component: index
},
]
})
2.在components文件夹下新建index文件夹,在index 文件夹下新建:index.vue
<template>
<div class="">
</div>
</template>
<script>
export default {
data () {
return {}
},
props: {},
computed: {},
components: {},
methods: {},
watch: {},
}
</script>
<style scoped>
</style>
3.绑定数据
1.单个数据绑定
<template>
<div class="content">
<span v-text="pageDate.id"></span>
<span v-text="pageDate.url"></span>
<span v-text="pageDate.href"></span>
</div>
</template> <script>
var pageDate =
{
id: 10000, //该广告的ID
url: 'http://163.com', //广告图片路径
href: 'http://baidu.com'//点击跳转连接
}
export default {
data () {
return {
pageDate
}
},
props: {},
computed: {},
components: {},
methods: {},
watch: {},
}
</script>
<style scoped>
</style>
2.多条数据绑定:
<template>
<!-- v-for 表情表示循环输出数据:必须要有父类dom,否则会出错的-->
<div>
<div v-for="item in pageDate">
<span v-text="item.id"></span>
<span v-text="item.url"></span>
<span v-text="item.href"></span>
</div>
</div>
</template>
<script>
var pageDate =[
{
id: 10000, //该广告的ID
url: 'http://163.com', //广告图片路径
href: 'http://baidu.com'//点击跳转连接
},
{
id: 10002, //该广告的ID
url: 'http://163.com', //广告图片路径
href: 'http://baidu.com'//点击跳转连接
}]
export default {
data () {
return {
pageDate
}
},
props: {},
computed: {},
components: {},
methods: {},
watch: {},
}
</script>
<style scoped>
</style>
3.增删改
<template>
<!-- v-for 表情表示循环输出数据:必须要有父类dom,否则会出错的-->
<div>
<div v-for="item in pageDate">
<span v-text="item.id"></span>
<span v-text="item.url"></span>
<span v-text="item.href"></span>
<button @click="detele()"> 删除数据</button>
</div>
<button @click="add"> 添加数据</button>
<button @click="update"> 修改数据</button>
</div>
</template>
<script>
var pageDate = [
{
id: 10000, //该广告的ID
url: 'http://163.com', //广告图片路径
href: 'http://baidu.com'//点击跳转连接
},
{
id: 10002, //该广告的ID
url: 'http://163.com', //广告图片路径
href: 'http://baidu.com'//点击跳转连接
}
]
export default {
data () {
return {
pageDate
}
},
props: {},
computed: {},
components: {},
methods: {
add: function () {
this.pageDate.push({
id: 10003, //该广告的ID
url: 'http://163.com', //广告图片路径
href: 'http://baidu.com'//点击跳转连接
})
},
update: function () {
this.pageDate[1].id = 10000000000000000000
},
detele: function (index) {
this.pageDate.splice(index, 1)
}
},
watch: {},
}
</script>
<style scoped>
</style>
vue 组件开发的更多相关文章
- vue前端开发那些事——vue组件开发
vue的学习曲线不是很陡(相比其它框架,如anglarjs),官方文档比较全面,分为基础篇和高级篇.我们刚开始学习的时候,肯定像引用jquery那样,先把vue的js引进来,然后学习基础内容.如果仅仅 ...
- Vue组件开发实例(详细注释)
Vue组件开发实例: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...
- Vue (三) --- Vue 组件开发
------------------------------------------------------------------好心情,会让你峰回路转. 5. 组件化开发 5.1 组件[compo ...
- vue 组件开发、vue自动化工具、axios使用与router的使用(3)
一. 组件化开发 1.1 组件[component] 在网页中实现一个功能,需要使用html定义功能的内容结构,使用css声明功能的外观样式,还要使用js定义功能的特效,因此就产生了一个功能先关的代码 ...
- 三: vue组件开发及自动化工具vue-cli
一: 组件化开发 1 组件 1: 组件(Component)是自定义封装的功能.在前端开发过程中,经常出现多个网页的功能是重复的,而且很多不同的网站之间,也存在同样的功能. 2: 什么是组件 而在网页 ...
- vue 开发系列(三) vue 组件开发
概要 vue 的一个特点是进行组件开发,组件的优势是我们可以封装自己的控件,实现重用,比如我们在平台中封装了自己的附件控件,输入控件等. 组件的开发 在vue 中一个组件,就是一个独立的.vue 文件 ...
- Vue组件开发实践之scopedSlot的传递
收录待用,修改转载已取得腾讯云授权 导语 现今的前端开发都讲究模块化组件化,即把公共的交互和功能封装到一个个的组件之中,在开发整体界面的时候就能像搭积木一样快速清晰高效.在使用Vue开发我们的vhtm ...
- Vue组件开发分享
在开始本文之前,你可能需要先了解以下相关内容: Vue.js 一款高性能轻量化的MVVM框架 Webpack 前端模块化代码构建工具 Vue组件介绍 基于vue.js高效的双向数据绑定特性,让我们 ...
- vue组件开发练习--焦点图切换
1.前言 vue用了有一段时间了,开发的后台管理系统也趋于完善,现在时间比较算是有点空闲吧!这个空闲时间我在研究vue的另外的一些玩法,比如组件,插件等.今天,我就分享一个组件的练手项目--焦点图切换 ...
- Vue 组件开发demo
1.代码地址 github:https://github.com/MengFangui/VueComponentDemo- 2.关键代码 (1)main.js //引入vue import Vue f ...
随机推荐
- Selenium chrome配置不加载图片Python版
环境: windows 7 + Python 3.5.2 + Selenium 3.4.2 + Chrome Driver 2.29 + Chrome 58.0.3029.110 (64-bit) f ...
- 2.Smarty的引入和实例化
1.把demo和lib复制出来,并且创建一个test文件夹作为工作的目录 如图所示: 2.这是libs里面的内容,其中smarty.class.php包含了smarty各种方法和功能,需要实例化它还工 ...
- window.onload的加载和$(document).read()
1.执行时机: window.onload :必须等到网页中所有的内容加载完之后才执行. $(document).read():网页中所有的DOM结构执行完毕后.可能DOM元素并未加载完. 2.单个网 ...
- Tomcat常用配置修改
Tomcat常用配置修改 说明 运行需要设置环境变量 JAVA_HOME 即JDK安装目录 tomcat 默认登录地址 http://localhost:8080 配置tomcat 1.端口设置 打开 ...
- Windows PowerShell 默认颜色
屏幕背景:1,36,86 屏幕文字:238,237,240 弹出文字:0,128,128 弹出窗口背景:255,255,255
- usaco training 3.4.3 fence9 题解
Electric Fence题解 Don Piele In this problem, `lattice points' in the plane are points with integer co ...
- JQuery EasyUI的常用组件
jQuery EasyUI 是一个基于 jQuery 的框架,集成了各种用户界面插件,该框架提供了创建网页所需的一切,帮助您轻松建立站点. 注:本次介绍的JQuery EasyUI版本为1.5版. 一 ...
- css 定位属性position的使用方法实例-----一个层叠窗口
运行结果: <!DOCTYPE html> <html> <head> <title>重叠样式窗口</title> <style ty ...
- 有关conv_std_logic_vector和conv_integer
原文地址:关于conv_std_logic_vector 和 conv_integer 这两个函数的使用问题作者:xiphosura std_logic_arithThis is the librar ...
- 面向对象15.3String类-常见功能-转换
public static void main(String[] args) { //2.1// String s="张三,李四,王五";// String [] arr=s.sp ...