嗨,在项目中,我已经包含了element-ui。
在app.js中:
import Element from 'element-ui'在此之后:
Vue.use(Element, {locale})因此,在我的单文件组件模板中,我可以像这样使用carousel:(在这个组件中,不是任何通过vue的初始化carousel,如import,parent等...)
<el-carousel>
<el-carousel-item>
<p>hello!</p>
</el-carousel-item>
</el-carousel>它起作用了。但。如何访问此元素?看一看实际的幻灯片,使用事件等....?
我在组件中尝试过类似这样的东西:
import { Carousel } from 'element-ui';并添加到组件列表...它可以工作,但它是这个类的另一个实例...
那么如何才能从DOM中获得真正的carousel实例呢?
发布于 2020-07-07 02:37:07
很简单。通过ref属性引用元素,如下所示:
<el-carousel ref="myreference"></el-carousel>在此访问之后:
console.log(this.$refs.myreference);https://stackoverflow.com/questions/62728043
复制相似问题