指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub

主要是vue3以后,不能通过 params 传递参数,以前路由跳转的时候,通过 params 传递参数很好用,官方建议用pinia

import { defineStore } from 'pinia'

export const useCourseVideoStore = defineStore({
    id: 'toCourseVideo',
    state: () => {
        return {
            courseId:0,
        }
    },
    actions: {
        setCourseId(val){
            this.courseId = val
        }
    },
    getters: {
        getCourseId(){
            return this.courseId
        }
    },
})

//使用
import { useCourseVideoStore } from '~/store/course-video'

const courseVideoStore = useCourseVideoStore()
      courseVideoStore.setCourseId(this.$route.params.id)
      
const courseVideoStore = useCourseVideoStore()
    let courseId  = courseVideoStore.getCourseId