运行小程序报:TypeError: Cannot read properties of undefined (reading ‘isStringliteral!)

用H5的项目,运行小程序报如下错误:
在这里插入图片描述在这里插入图片描述
思路:首先排查花括号 {{}} 是否为空。
解决办法:
如果实在找不到问题出在哪里,可以现在F:\代码编辑器\HBuilderX.3.8.12.20230817\HBuilderX\plugins\uniapp-cli\node_modules@dcloudio\uni-template-compiler\lib这个中util.js修改代码,代码如下:

if(!path || path == null || path == undefined) {
    console.log(path,'是否包含转义引号')
  }else {
    if (path.isStringLiteral()) {
      return hasEscapeQuote(path.node)
    } else {
      path.traverse({
        noScope: true,
        StringLiteral (path) {
          if (hasEscapeQuote(path.node)) {
            has = true
            path.stop()
          }
        },
        TemplateElement (path) {
          if (path.node.value.cooked.includes('\'')) {
            has = true
            path.stop()
          }
        }
      })
    }
  }

还有F:\代码编辑器\HBuilderX.3.8.12.20230817\HBuilderX\plugins\uniapp-cli\node_modules@dcloudio\uni-template-compiler\lib\script\traverse中visitor.js修改代码,代码如下:

if(stringPath) {
              const stringNodes = stringPath.node
              stringNodes.$toString = true
              path.replaceWith(stringNodes)
            }

改完这两个地方,项目在微信开发者工具中就可以运行了,个别问题就个别分析。然后就是需要你看看页面有没有问题等等,就可以找到是哪里出的问题了。

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你遇到错误"TypeError: Cannot read properties of undefined (reading 'get')",通常是因为你正在尝试访问一个未定义的属性或方法。根据你提供的引用内容,这个错误可能是由不同的原因造成的。 首先,根据引用,这个错误可能是由于Vuex版本问题引起的。如果你在使用Vuex时遇到这个错误,可能是因为你正在使用的Vuex版本与你的Vue版本不兼容。如果你在Vue2中学习,你可能需要使用Vue2版本的Vuex。你可以尝试下载Vue2版本的Vuex来解决这个问题。 其次,根据引用,这个错误可能是由于在调用接口时没有正确返回Promise对象引起的。在你的代码中,getVirusInfo方法没有正确返回axios.get的结果。你需要在getVirusInfo方法中添加return来返回Promise对象。这样,你才能在created钩子中正确使用then方法来处理异步请求的结果。 综上所述,要解决"TypeError: Cannot read properties of undefined (reading 'get')"错误,你可以检查Vuex和Vue版本是否匹配,并确保在调用接口时正确返回Promise对象。这样,你就可以成功访问和使用相关方法了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [vue.esm.js:3767 TypeError: Cannot read properties of undefined (reading ‘dispatch‘)](https://blog.csdn.net/weixin_46029637/article/details/131992019)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [错: TypeError: Cannot read properties of undefined (reading ‘then‘)](https://blog.csdn.net/sen123456m/article/details/126303572)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值