Vue3 + ts + webpack
在public/index.html引入其他js工具库
调用js库提示以下错误:

‘get’ on proxy: property ‘provider’ is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value (expected ‘#’ but got ‘#’)

调用工具库内部就报错,不调用就不报错,那问题就在这个调用工具库那个区块使用上。
网上大量搜查,发现是赋值的参数绑定这个双向绑定。
js工具库赋值给 ref 或 reactive 声明的变量导致的。
问题代码:
js工具库:test.js

const params = ref(null)
params.value =  testJS.init()
params.value.testJSMethods()  再次调用js工具库内的函数就抛出异常

或

const  dataAll= reactive({
	params: ''
})
dataAll.params =  testJS.init()
dataAll.params.testJSMethods()  再次调用js工具库内的函数就抛出异常

方法一

修正,params参数声明不要使用双向绑定(ref,reactive)。


window.params =  testJS.init()

window.params.testJSMethods() 

这个修改就成功了,大家也可以不用绑定在window上,可以用其他的方式存储变量,不是双向(ref,reactive)的就行。

方法二

import { markRaw,toRaw } from 'vue';

const params = ref(null)

params.value = markRaw( testJS.init())  //获取原始数据设置
or 
params.value = toRaw( testJS.init())  //获取原始数据设置

params.value.testJSMethods()  

Logo

前往低代码交流专区

更多推荐