代码如下,记得加判断
const store = useStore()
store.SetIsMobile(window.innerWidth < 768)
// process.client 用于判断是否在客户端渲染
if (process.client) {
_.throttle(() => {
window.addEventListener('resize', () => {
store.SetIsMobile(window.innerWidth < 768)
})
}, 100)()
}