Comments (13)
复现代码输出不了你截图的日志吧。
from vue-echarts.
复现代码输出不了你截图的日志吧。
我仓库的代码复现不了吗
from vue-echarts.
复现代码输出不了你截图的日志吧。
两次截图分别是打包前和打包后a的值
b的值是正常的,我就没截图
from vue-echarts.
我仓库的代码复现不了吗
复现不了,你检查一下吧
from vue-echarts.
我仓库的代码复现不了吗
复现不了,你检查一下吧
可以复现啊
我准备了个在线的
https://stackblitz.com/~/github.com/Preyou/vue-project?file=src/App.vue
from vue-echarts.
我仓库的代码复现不了吗
复现不了,你检查一下吧
可以复现啊
我准备了个在线的 https://stackblitz.com/~/github.com/Preyou/vue-project?file=src/App.vue
直接运行 pnpm run preview
再看控制台就可以发现,没有正确的获取实例
from vue-echarts.
mount 以前 ref 的 value
应该是 undefined
吧,你这么写如果能取到值那肯定是因为热更新导致的。这在生产环境肯定不对啊。
from vue-echarts.
mount 以前 ref 的
value
应该是undefined
吧,你这么写如果能取到值那肯定是因为热更新导致的。这在生产环境肯定不对啊。
我这么写是没问题的,我打印的是ref而不是ref.value。而且就算是把log写在onMounted里,一样不行。
from vue-echarts.
我试了一下在 preview 下取到组件实例是没有问题的,你不要看 console 打出来的内容,你试试实际调用实例上的方法看看。
from vue-echarts.
我试了一下在 preview 下取到组件实例是没有问题的,你不要看 console 打出来的内容,你试试实际调用实例上的方法看看。
确实是可以调用的,但是属性不可枚举还是有点问题的,在实现组件继承时,为了连expose一起继承,我可能会这么写
const chart = reactive({})
defineExpose(chart)
onMounted(()=>{
Object.assign(chart, chartInstance.value)
})
这里当然可以改成
defineExpose({
chart: chartInstance
})
但是这样写的话,每次调用包装后的组件都得多访问一层chart
包装前
const echart = ref()
onMounted(()=>{
echart.value.dispatchAction({})
})
包装后
const echart = ref()
onMounted(()=>{
echart.value.chart.dispatchAction({})
})
但是我包装组件的目的主要是为了全局覆写一些默认参数(比如theme
),避免每个调用的地方都要再写一遍。并不想改变原有组件的用法,以便其他开发人员可以在仅参考原有文档的基础上就能使用包装后的组件。
而且我不太清楚为何这个组件打包后所有的实例属性都不可枚举了,这使得某些依赖迭代器的用法都会在打包前后的表现不一致。比如for in
、...obj
、Object.assign
、Object.keys
、Object.values
、Object.entries
等,都将无法在打包后正确拿到属性。
from vue-echarts.
这个和 Vue ECharts 无关的,你搞一个只包含 Vue 的项目试一下,也是这样的。
from vue-echarts.
这个和 Vue ECharts 无关的,你搞一个只包含 Vue 的项目试一下,也是这样的。
我在示例里不是还打印了一个变量b
吗,这个b
就是正常可枚举的。
from vue-echarts.
你搞一个不是通过 defineExpose
定义的实例。
from vue-echarts.
Related Issues (20)
- Remove vue demi HOT 1
- From version 6.6.1 setting min-height make the chart disappear (height=0px) HOT 1
- Default ESM package HOT 2
- chart not appear when using option dataset with source HOT 1
- Native listener on VueEcharts Component does not work in Vue 3 HOT 4
- Types broken with ECharts 5.5 + Vue 3 + `moduleResolution: bundler` HOT 1
- useAutoresize throttle switch to requestAnimationFrame method HOT 3
- Nuxt 3 Module HOT 1
- Renderer 'undefined' is not imported. Please import it first. HOT 8
- autoresize prop doesn't work as expected from 6.6.1 HOT 1
- 官网的import code generator似乎不能正常工作了 HOT 1
- h5手机端支持吗?手机端的点击事件能触发吗? HOT 1
- Unable to compile after the introduction of vitepress, error: ERR-REQUIRE-ESM
- 路由缓存时,切换Tab页面,ECHARTS不显示 HOT 3
- 安装报错 Invalid response body while trying to fetch https://registry.npmjs.org/resize-detector: Cannot read properties of null (reading 'pickAlgorithm') HOT 2
- `npm i echarts vue-echarts` not installing for vue3 project HOT 1
- 使用dataset数据集多纬度时报错 HOT 3
- vue-echart instance doesn't have off function HOT 5
- 示例代码显示内容空白 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-echarts.