1.路由跳转传参,使用query方式可以防止刷新丢失数据

发起页面

# 带参数
    toArticleInfo(blogId){
      this.$router.push(
        {
          path: '/blog/info',
          query: {
            blogId: blogId,
          }
        }
      )
    },


// 字符串
<router-link to="apple"> to apple</router-link>
// 对象
<router-link :to="{path:'apple'}"> to apple</router-link>
// 命名路由
<router-link :to="{name: 'applename'}"> to apple</router-link>
//直接路由带查询参数query,地址栏变成 /apple?color=red
<router-link :to="{path: 'apple', query: {color: 'red' }}"> to apple</router-link>
// 命名路由带查询参数query,地址栏变成/apple?color=red
<router-link :to="{name: 'applename', query: {color: 'red' }}"> to apple</router-link>
//直接路由带路由参数params,params 不生效,如果提供了 path,params 会被忽略
<router-link :to="{path: 'apple', params: { color: 'red' }}"> to apple</router-link>
// 命名路由带路由参数params,地址栏是/apple/red
<router-link :to="{name: 'applename', params: { color: 'red' }}"> to apple</router-link>

接收页面

  activated () {
    this.article.blogId = this.$route.query.blogId
    console.log(this.article.blogId)
  }

2.解析md文档

# 解析md文档
npm install markdown-it --save
# md样式
npm install github-markdown-css

3.前端js无法处理大数据精度问题

const http = axios.create({
  timeout: 1000 * 30,
  withCredentials: true,
  headers: {
    'Content-Type': 'application/json; charset=utf-8'
  },
  // 定制 axios 配置项 transformResponse 处理返回结果,处理bigint在前端精度损失问题 npm install json-bigint
  transformResponse: [function (data){
    return JSONbig.parse(data)
}],
})
Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐