标签:ges div strong import show 依赖 ack nbsp 第一步
一、require(‘../assets/1.jpg‘) 图片通过js引入到项目中,使用require为了使webpack返回正确的资源路径

二、使用Router
第一步:router配置
//使用router第一步:router配置 import Router from ‘vue-router‘
第二步:注册router
//使用router第二步:router注册 Vue.use(Router)
第三部:router的map
import IndexPage from ‘../pages/IndexPage‘
export default new Router({ //router的map
routes: [
{
path: ‘/‘,
name: ‘IndexPage‘,
component: IndexPage
}
]
})
三、创建任何组件,
1、先建 .vue单文件 2、引入组件 import slideShow from ‘../components/Slide‘ 3、注册组件 components
四、学会使用计算属性
有时候使用方法也可以实现,但是更多的使用计算属性
computed:{
//最开始想到的是用方法实现效果,但是推荐计算属性,
preIndex:function(){
if(this.newIndex==0){
return this.slides.length-1
}else{
return this.newIndex-1
}
}
}
计算属性是基于它们的依赖进行缓存的。计算属性只有在它的相关依赖发生改变时才会重新求值。方法不会缓存
标签:ges div strong import show 依赖 ack nbsp 第一步
原文地址:https://www.cnblogs.com/yongyang/p/9182276.html