vuejs / docs

📄 Documentation for Vue 3
https://vuejs.org
Other
2.81k stars 4.1k forks source link

setup 使用extends 生产环境报错,文档写的是不建议 #2811

Closed qiaokeli111 closed 3 weeks ago

qiaokeli111 commented 1 month ago

"vue": "^3.3.11" “vite”:"5.0.8"

开发环境与生产环境的qq.setup(props, ctx)不一致,开发环境返回对象可以正常使用,生产环境返回函数无法进行修改

import qq from "./qq.vue"; var se = { extends: qq, setup(props, ctx) { return qq.setup(props, ctx) }, } 期望把 此段文档进行修改 1713516282368

brc-dd commented 1 month ago

开发环境返回对象可以正常使用,生产环境返回函数无法进行修改

Can you explain what are you trying to do, preferably with code that works in dev but not in prod?

qiaokeli111 commented 1 month ago

开发环境返回对象可以正常使用,生产环境返回函数无法进行修改

Can you explain what are you trying to do, preferably with code that works in dev but not in prod?

Okay, let me give a simple example import Base from './Base.vue' export default { extends: Base, setup(props, ctx) { return { ...Base.setup(props, ctx), // 本地绑定 } } } This is an official document example for Vue,I just changed the .js suffix of base to .vue This code can be used in the development environment, but there may be issues in the production environment Because the setup function in the production environment returns a function that cannot be used ... To convert

bencodezen commented 3 weeks ago

For issues related to the Chinese docs site, please create issues at the official repo https://github.com/vuejs-translations/docs-zh-cn. Thank you!

brc-dd commented 3 weeks ago

Ah, it's an issue with English docs too. Probably needs just a note that it won't work with .vue files. (That snippet currently works in dev for SFCs, but not in prod.)

qiaokeli111 commented 3 weeks ago

Ah, it's an issue with English docs too. Probably needs just a note that it won't work with .vue files. (That snippet currently works in dev for SFCs, but not in prod.) you are right, Both English and Chinese documents have this issue,all need change