vue基础篇(2)

vue基础篇(2)

"""
1、箭头函数 let fn = (a, b) => a + b;
    let 函数名 = (参数列表) => {函数体}

2、函数原型:给函数设置原型 Fn.prototype.变量 = 值,那么Fn new出来的对象都可以共用 原型变量
    function Fn() {}
    let f1 = new Fn()
    let f2 = new Fn()
    Fn.prototype.fn = () => {}
    Fn.prototype.fn2 = function () {}
    f1.fn()
    f2.fn()

3、vue项目的请求生命周期:main.js完成环境的加载与根组件的渲染;router的index.js完成路由映射
    项目启动:加载main.js:index.html、new Vue()、Vue、router、store、完成App.vue的挂载
    请求:请求路径 => router路由 => 页面组件(小组件) => 替换<router-view />完成页面渲染 => <router-link>(this.$router.push())完成请求路径的切换
    
4、<router-view />标签作为路由映射的页面组件占位符
5、<router-link></router-link>来完成路由的跳转
    <router-link to="/1" :to="{name:'home', params={arg: 1}}">主页</router-link>
    
    {
        path: '/:arg',
        name: 'home',
        component: Home
    }
    
6、this.$router来完成路由的跳转:push() | go()
    this.$router.push('/1');
    this.$router.push({name:'home', params={arg: 1}});
    this.$router.go(-1);
    this.$router.go(1);

7、this.$route来完成路由的传参
    this.$route.params.arg
    this.$route.params['arg']
    
8、资源的加载
    require(资源的相对路径)
"""

猜你喜欢

转载自www.cnblogs.com/jhpy/p/11869024.html