问题记录1

问题1 vue3使用v-bind的问题

报错 [vite] Internal server error: Error parsing JavaScript expression: Unexpected token (2:16)
在这里插入图片描述
原因是v-bind,即使这段代码注销了也会报错

.checked {
  //background-color: v-bind() ;
  &::before {
    display: inline-block;
    content: "";
    background-color: white;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin: 0 2px 0 0;
  }
}

问题2 vue3使用Driver.js的问题

蒙版效果底部的元素会消失,原因是组件使用了 position: fixed; 布局 ,网上的解决方法有好几种,但是似乎有效的就是改为:relative或absolute 等布局

问题3 vue3的i18n的多语言动态切换问题

onMounted(()=>{
 driver= new Driver({
  // 禁止点击蒙版
  allowClose:false,
  closeBtnText: i18n.t('msg.guide.close'),
  nextBtnText: i18n.t('msg.guide.next'),
  prevBtnText: i18n.t('msg.guide.prev'),
})
})
// 点击启动
const onClick=()=>{
 driver.defineSteps(steps(i18n))
  driver.start()
  }

这样写i18n.t()切换与以后不会立即切换语言,应该写在点击事件里面,每次点击重新执行:i18n.t()

// 点击启动
const onClick=()=>{

 driver= new Driver({
  // 禁止点击蒙版
  allowClose:false,
  closeBtnText: i18n.t('msg.guide.close'),
  nextBtnText: i18n.t('msg.guide.next'),
  prevBtnText: i18n.t('msg.guide.prev'),
})

 driver.defineSteps(steps(i18n))
  driver.start()
  }

i18n.t(),必须在回调函数中重新赋值,不然会保留之前的只

4 在setup之外使用pinia

很多时候我们会在组件之外使用pinia,例如:在router中使用,或组件更早的地方使用pinia存储数据
方法,他和vuex有不同,vuex
创建
store.js

import { createPinia } from "pinia";
const pinia = createPinia();
export default pinia;

main.js中

// import { createPinia } from 'pinia'
import     pinia      from "../src/stores/store"
app.use(pinia)

router.js中使用

import { useLanguageStore  } from "../stores/language"
import pinia from  "../stores/store"

const store = useLanguageStore(pinia)// 这里一定要把 pinia传入进去

5 解决Cannot read properties of null (reading ‘pickAlgorithm‘) ,‘react-scripts’ 不是内部或外部命令,也不是可运行的程序

解决方法:
在终端输入: npm cache clear --force

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值