We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
开发组件库时组件内部处理逻辑对外暴露容易对使用者带来困扰,希望能提供类似组件内部私有数据和方法如下:
export default Btn { name: 'Bth',
setup(props){ // 内部数据 & 方法, 不对外部访问 const bth = ref(null) const handlerClick = e => { // 在出发点击事件前做点什么 props.onClick(e) } // 公共数据 & 方法对外部公开 const click = () => btn.value.click() const focus = () => btn.value.focus() return { // 对外部公开的数据 & 方法 click: click, focus: focus, // 组件渲染函数 render:function(){ return h('button', { ref: btn, onClick: handlerClick }, '按钮') } } }
}
// 使用组件 // 调用组件方法 this.$refs.btn.click()
before: setup() { // return { name:'CY' } // OR return function render(){} }
after: setup() { // return { name:'CY' } // OR // return function render(){} // OR return { // 模板数据 name:'CY', // 渲染函数 render:function(){} } }
The text was updated successfully, but these errors were encountered:
Please check the RFC about expose vuejs/rfcs#210. Also, you can ask questions on the forum, the Discord server or StackOverflow first.
expose
Sorry, something went wrong.
No branches or pull requests
What problem does this feature solve?
开发组件库时组件内部处理逻辑对外暴露容易对使用者带来困扰,希望能提供类似组件内部私有数据和方法如下:
export default Btn {
name: 'Bth',
}
// 使用组件
// 调用组件方法
this.$refs.btn.click()
What does the proposed API look like?
before:
setup() {
// return { name:'CY' }
// OR
return function render(){}
}
after:
setup() {
// return { name:'CY' }
// OR
// return function render(){}
// OR
return {
// 模板数据
name:'CY',
// 渲染函数
render:function(){}
}
}
The text was updated successfully, but these errors were encountered: