【Vue3.x】Alarm

221 阅读1分钟

1. Missing required prop: "index"

image.png

image.png

2. Invalid prop: type check failed for prop “router“. Expected Boolean, got String with value “true“.

image.png

我们是用ElementPlus,是导航的时候出现了警告

image.png

image.png

3. 'xxxxx' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled.ts

image.png

image.png

4. "getActivePinia()" was called but there waw no active pinia. Ara you trying to use a store before calling "app.use(pinia)"

image.png

5. RangeError: Maximum call stack size exceeded

router.beforeEach()死循环

//如下所示,else的时候做一个判断
router.beforeEach((to, from, next) => {
  if (!isMobile()){ // PC端访问
    console.log("PC端访问")
    if (to.path !== '/login' && to.path !== '/register' && !isLogin()) {
      return next('/login')
    }
    next()
  }
  else {
    console.log("移动设备")
    if (to.path == '/tip'){  //关键所在:如果要跳转的路径是/tip才放行
      next()
    }
    else {
      next('/tip')
    }
  }
})

6. inject() can only be used inside setup() or functional components

image.png

7. Type 'unknown' is not assignable to type 'string'

image.png

async function changeTalkLove() {
  person.value.talkLove = await loveTalk() as string;
  console.log('api result :', person.value.talkLove)
}