Closed aloha66 closed 2 years ago
cli 更新至:3.0.0-alpha-3030020211201002
cli 更新至:3.0.0-alpha-3030020211201002
大佬,3.0.0-alpha-3030020211201003用这个版本之后,inject 的内容undefined
import { inject } from 'vue-demi'
const contextConfig = inject('UseRequestConfigContext', {})
console.log('contextConfig', contextConfig) // undefined
import { inject } from 'vue-demi' const contextConfig = inject('UseRequestConfigContext', {}) console.log('contextConfig', contextConfig) // undefined
查看: https://github.com/vueuse/vue-demi 的文档 你需要在vite.config.js中配置:
optimizeDeps: { exclude: ["vue-demi"], },
如果不考虑同时兼容vue2,vue3,建议使用vue本身提供的功能
import { inject } from 'vue-demi' const contextConfig = inject('UseRequestConfigContext', {}) console.log('contextConfig', contextConfig) // undefined
查看: https://github.com/vueuse/vue-demi 的文档 你需要在vite.config.js中配置:
optimizeDeps: { exclude: ["vue-demi"], },
如果不考虑同时兼容vue2,vue3,建议使用vue本身提供的功能
大佬有个问题想请教一下,是这样的: 我在写一个通用的useRequest(之前已经完成一版,在生产环境也做了exclude: ["vue-demi"],运行正常)。 现在有些功能在改动,uni项目有些bug,所以yarn link了开发环境的代码以方便调试。 在20211201003之前开发环境没有exclude: ["vue-demi"],也运行正常,想问一下为什么20211201003版本需要exclude呢?
import { inject } from 'vue-demi' const contextConfig = inject('UseRequestConfigContext', {}) console.log('contextConfig', contextConfig) // undefined
查看: https://github.com/vueuse/vue-demi 的文档 你需要在vite.config.js中配置:
optimizeDeps: { exclude: ["vue-demi"], },
如果不考虑同时兼容vue2,vue3,建议使用vue本身提供的功能
大佬有个问题想请教一下,是这样的: 我在写一个通用的useRequest(之前已经完成一版,在生产环境也做了exclude: ["vue-demi"],运行正常)。 现在有些功能在改动,uni项目有些bug,所以yarn link了开发环境的代码以方便调试。 在20211201003之前开发环境没有exclude: ["vue-demi"],也运行正常,想问一下为什么20211201003版本需要exclude呢?
之前的版本,编译器内部强制禁用了optimizeDeps,新版本不再做限制
thx
<script lang="ts">
export default defineComponent({
props: ['test'],
setup(props) {
const comp = computed(() => {
return props.test.demo.value + '123'
})
return {
comp,
}
},
})
</script>
<template>
<view>
{{ test }}
<view>{{ comp }}</view>
</view>
</template>
props.test.demo.value
在小程序.value
的值是undefined
,没有.value
能正常显示。目测是小程序的js部分漏了unref?看了你之前修改的代码也不知道在哪里修改:sweat: @fxy060608
<script lang="ts"> export default defineComponent({ props: ['test'], setup(props) { const comp = computed(() => { return props.test.demo.value + '123' }) return { comp, } }, }) </script> <template> <view> {{ test }} <view>{{ comp }}</view> </view> </template>
props.test.demo.value
在小程序.value
的值是undefined
,没有.value
能正常显示。目测是小程序的js部分漏了unref?看了你之前修改的代码也不知道在哪里修改😓 @fxy060608
目前是有问题,在小程序平台,会对 props 数据进行 unref,稍后解决一下 ref 的问题
@aloha66 cli 可以更新至:3.0.0-alpha-3030020211207001 本次更新,对 props 的相关逻辑做了底层重构,比较完整的支持了 vue 的 props 用法(包括支持函数,响应式等复杂对象类型) 你可以更新验证下相关功能是否正常
看了一下代码,工作量好像挺大的 辛苦了
问题描述 在h5可以正常输出 在微信小程序不能输出 不知道是平台限制还是bug
试过用toRefs,可以正常显示。 但也有两个问题
复现步骤
系统信息: