【发布时间】:2019-06-08 14:33:24
【问题描述】:
我是 Vuejs 新手,slot-scope 有一些问题,
<template>
<some-component>
<div slot-scope="{someMethod, someData}">
// the problem is i need someMethod in my current component, not in template
</div>
</some-component>
</template>
<script>
export default {
created() {
// i need to access someMethod and someData here
this.someMethod();
}
}
</script>
有可能吗? 最佳实践方式是什么?
【问题讨论】:
-
可能有更好的方法来解决这个问题。
someMethod是做什么的? -
类似初始化表单的东西
-
我不确定这个问题对于插槽是否有意义。这个小提琴能回答你的问题吗? jsfiddle.net/posva/uzd56xv2
标签: vue.js vuejs2 vue-component vuex vue-router