Giter Club home page Giter Club logo

Comments (9)

ydcss avatar ydcss commented on August 20, 2024

你好,请问this指向谁?

from vue-ydui.

 avatar commented on August 20, 2024

this指向的是当前组件吧,我是在入口文件中Vue.use(YDUI)

from vue-ydui.

ydcss avatar ydcss commented on August 20, 2024

可否看看你的代码呢?

from vue-ydui.

 avatar commented on August 20, 2024

我把文档示例代码放到.vue组件里面是一样的效果,Error in mounted hook: (found in )
TypeError: Cannot read property '$on' of undefined

from vue-ydui.

ydcss avatar ydcss commented on August 20, 2024

你好,感谢你提出的问题,现问题已经修复,但稍微改动下原来的调用方法。原 this.$yduiBus.$emit() 改为 window.$yduiBus.$emit()。

from vue-ydui.

290115231 avatar 290115231 commented on August 20, 2024

`


<yd-button @click.native="show1 = true" size="large">带取消

    <yd-actionsheet :items="myItems1" v-model="show1" cancel="取消"></yd-actionsheet>
</div>
<script type="text/babel"> export default { data() { return { show1: false, myItems1: [ { label: '拍照', method: () => { this.$dialog.toast({mes: '咔擦,此人太帅!'}); /* 注意: method: function() {} 和 method() {} 这样是无法正常使用当前this的 */ } }, { label: '从相册中偷取', method: () => { this.$dialog.toast({mes: '看到了不该看到的东西!'}); } } ] } } } </script>

你好,我在调用这个组件的时候,调用item的method时会报错this是未定义的。 以下是我的webpack的配置文件
module.exports = {
entry: "./entry.js",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test:/.css$/, loader: "style-loader!css-loader"},
{ test:/.vue$/, loader: "vue-loader"}
],
},
resolve: {
alias: {
vue: 'vue/dist/vue.js'
}
}
}
`
请问我是什么地方出错了呢,谢谢! @ydcss

from vue-ydui.

ydcss avatar ydcss commented on August 20, 2024

你好,单独引用dialog组件正常吗?
export default { mounted() { this.$dialog.toast({mes: '咔擦,此人太帅!'}); } }

from vue-ydui.

290115231 avatar 290115231 commented on August 20, 2024

不行哦,Uncaught TypeError: Cannot read property 'toast' of undefined,这是报错的信息。

这是我打印出来的this。
qq 20170327172339

@ydcss

from vue-ydui.

ydcss avatar ydcss commented on August 20, 2024

同学们注意啦!官方示例代码中“yd-actionsheet”组件调用了“this.$dialog”组件,若为按需引用组件需另引入dialog组件。

from vue-ydui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.