今天分享个自己在工作中遇到的头疼问题,记录下,在使用pinia时,引入use模块,h5端没问题,我使用的是vue3,运行在APP端一直报错:
reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->
at useStore (app-service.js:9864:15)
at (app-service.js:16358:3)
at (app-service.js:29793:3)
琢磨了几小时,最终发现问题所在了,原因是我在useUser时,是在setup函数外调用的,以下是我的错误代码示例
<script>
import { useUser } from '@/store/user.js'
const userTask = useUser() // 不能在setup外中使用,会报错
export default {
setup() {
...
}
}</script>解决方案:
1. 使用setup语法糖
<script setup>import { useUser } from '@/store/user.js'const userTask = useUser() // 在setup语法糖中使用</script>2. 在setup函数内使用
<script>
import { useUser } from '@/store/user.js'
export default {
setup() {
const userTask = useUser() // 在setup函数中使用
...
}
}</script>问题解决!
由于工作需要长期使用Ajax,一个页面重复的AJAX请求太多,于是封装起来,只需要编写回调函数/* ------------- 使用方法: 1.ajaxrequest()函数执行准备的参数(1.请求地址2.发送数据字符串拼接3.type值可选get/post4.回调函数名称) exam...
离线缓存的开启实例使用apache设置 1.apache配置文件搜索Addtype,我的addtype已经存在项目,如下 AddType application/x-compress .Z AddType application/x-gz...
https://3gimg.qq.com/lightmap/v1/marker/index.html?marker=coord:37.6767600000,112.7297800000&key=TKUBZ-D24AF-GJ4JY-JDVM2-IBYKK-KEBCU&referer=p...
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> ...
二期项目中生成的简历二维码是使用canvs生成的,微信浏览器中不能识别二维码,只能扫码。懒的换phpqrcode,于是转canvs。//设置一个url var url = "{yun:}$config.sy_weburl{/yun}/mingli/index....
查看文章前你需要了解以下2点://1.this指向的是windows对象,通过console.log(this)可以查看到对象包含所有的方法和属性//2.全局变量属于this对象的属性通过console.log(this)可以查看到对象包含我们设置的全局变量我们经常在创建相同结构的Js对象会重复的设...