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(资源的相对路径)
"""
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步