Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qiaokeli111 opened this issue Apr 19, 2024 · 6 comments
Closed

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

qiaokeli111 opened this issue Apr 19, 2024 · 6 comments

Comments

@qiaokeli111
Copy link

"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
Copy link
Member

brc-dd commented Apr 19, 2024

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

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

@brc-dd brc-dd added the need more info Further information is requested label Apr 19, 2024
@qiaokeli111
Copy link
Author

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

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

@brc-dd brc-dd added contribution welcome and removed need more info Further information is requested labels Apr 19, 2024
@bencodezen
Copy link
Member

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
Copy link
Member

brc-dd commented Apr 24, 2024

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
Copy link
Author

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

@self-imrovement
Copy link

self-imrovement commented Oct 16, 2024

have any solutions for SFCs in prod ?
@bencodezen @brc-dd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants