0515vue

82 阅读1分钟
路由

前置路由:beforeEach(()=>{})路由切换前 路由元:meta{} 后置路由:路由切换后 例如title next()之后才更改 重复多 所以写在后置路由里 注意后置路由没有next() 仅 to from 独享路由守卫:某一个路由所独享的 只有beforEnter: to from next 在进入某一个单独路由之前 组件内路由守卫:beforeRouteEnter() 通过路由规则,进入该组件时被调用 beforeRouteLeave()通过路由规则,离开该组件时被调用

部署
  1. npm run build 打包完成的项目
  2. 用node.js + express 建服务器部署项目
  3. npm init 定义包的名字
  4. npm i express
  5. 接着创建一个服务器主文档 server.js
const express = require('express')

const app = express()
app.use(express.static(__dirname+'/static'))
app.get('/person',((req,res) =>{
    res.send({
        name:'tom',
        age:18
    })
} ))
app.listen(5005,(err)=>{
    if(!err){
        console.log('服务器启动成功了!')
    }
})
  1. node server
element-ui

全局引入 按需引入

除了数据 property,Vue 实例还暴露了一些有用的实例 property 与方法。它们都有前缀 $,以便与用户定义的 property 区分开来。