鍍金池/ 問(wèn)答/HTML/ vue中prop傳入的method讓其this指向外部組件?

vue中prop傳入的method讓其this指向外部組件?

    //Father組件
    <template>
        <Children :remoteMethod="remoteMethod" />
    </template>
    <script>
        export default{
            methods: {
                remoteMethod() {
                    //想讓這里this指向Father,而不是指向Children
                    console.log(this)
                }
            }
        }
    </script>
    
    //Children組件
    <script>
        export default{
            props: {
              remoteMethod: {
                type: Function
              }
            }
        }
    </script>
回答
編輯回答
拽很帥

this.$parent

2018年4月19日 02:10
編輯回答
練命

麻煩點(diǎn)的話,傳入個(gè)父方法,然后父方法里面有進(jìn)行邏輯判斷

2018年4月5日 05:22