Subscribe on changes!

provide/inject 在rollup打包时产生的问题

avatar
Jun 24th 2021

Version

3.1.2

Reproduction link

[https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8ZGl2PlxuICA8L2Rpdj5cbjwvdGVtcGxhdGU XG5cbjxzY3JpcHQ XG4gIGltcG9ydCB7cHJvdmlkZX0gZnJvbSAndnVlJ1xuICBleHBvcnQgZGVmYXVsdHtcbiAgICBzZXR1cDpmdW5jdGlvbiBzZXR1cChwcm9wcyl7XG4gICAgICBwcm92aWRlKCdhYWEnLCdiYmInKVxuICAgICAgcmV0dXJuIHt9O1xuICAgIH1cbiAgfVxuPC9zY3JpcHQ XG4ifQ==](https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8ZGl2PlxuICA8L2Rpdj5cbjwvdGVtcGxhdGU XG5cbjxzY3JpcHQ XG4gIGltcG9ydCB7cHJvdmlkZX0gZnJvbSAndnVlJ1xuICBleHBvcnQgZGVmYXVsdHtcbiAgICBzZXR1cDpmdW5jdGlvbiBzZXR1cChwcm9wcyl7XG4gICAgICBwcm92aWRlKCdhYWEnLCdiYmInKVxuICAgICAgcmV0dXJuIHt9O1xuICAgIH1cbiAgfVxuPC9zY3JpcHQ XG4ifQ==)

Steps to reproduce

打包前ts setup: (props) => { ... provide('aaa', 'bbb'); ... } 打包后 setup: function setup(props) { ... vue.provide('aaa', 'bbb'); ... } rollup配置中使用了external['vue'] 与output.globals={vue:'vue'} 排除vue包

What is expected?

在子组件与vue工具中可以看到名为aaa值为'bbb'的provider

What is actually happening?

浏览器控制台报错runtime-core.esm-bundler.js:38 [Vue warn]: provide() can only be used inside setup()

avatar
Jun 24th 2021

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server or StackOverflow.


Your repro link doesn't work and you should use English in issues