嗨哆嚒
嗨哆嚒
  • 发布:2020-08-24 16:34
  • 更新:2020-08-24 16:53
  • 阅读:858

app端如何引入单独的js文件

分类:uni-app

在页面内引入
import Scratch from '@/common/scratch'
或者挂载到全局,
Vue.prototype.$Scratch = Scratch;
结果都是H5支持,app端报错,报错结果如下:
Property or method "touchStart" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

2020-08-24 16:34 负责人:无 分享
已邀请:
爱吃鱼的靖哥哥

爱吃鱼的靖哥哥 - 行走在全栈路上的码农

你这个js是怎么写的啊,我都是每个页面单独引用的,可以正常使用啊

  • 嗨哆嚒 (作者)

    放在公共文件夹或者同一目录都一样。是一个构造函数,H5端没问题,app就报错

    2020-08-24 16:41

  • 爱吃鱼的靖哥哥

    回复 嗨哆嚒: 好吧,估计是你的写法有问题

    2020-08-24 16:42

  • 嗨哆嚒 (作者)

    回复 爱吃鱼的靖哥哥: import Scratch from '@/common/scratch'

    new Scratch(this, {

    canvasId: 'canvas-id',

    width: this.scratchWidth,

    height: this.scratchHeight,

    size: this.scratchSize,

    scale: this.scratchScale

    })

    2020-08-24 16:51

  • 爱吃鱼的靖哥哥

    回复 嗨哆嚒: 没有export吗

    2020-08-24 16:53

  • 嗨哆嚒 (作者)

    回复 爱吃鱼的靖哥哥: 有的,H5正常

    2020-08-24 17:17

深海智行

深海智行 - 专注前端培训

Scratch 是哪里来的?是否有说明支持情况?是否有使用到DOM、BOM?

  • 嗨哆嚒 (作者)

    import Scratch from './scratch',没有DOM和BOM

    2020-08-24 17:18

  • 深海智行

    回复 嗨哆嚒: 哦,我说的哪里来的,意思是哪里来的(比如小王给的)

    2020-08-24 17:25

  • 嗨哆嚒 (作者)

    回复 深海智行: 博客,不支持DOM和BOM操作

    2020-08-24 17:27

该问题目前已经被锁定, 无法添加新回复