GithubHelp home page GithubHelp logo

详解vue组件三大核心概念 about blog HOT 9 OPEN

ljianshu avatar ljianshu commented on May 25, 2024 2
详解vue组件三大核心概念

from blog.

Comments (9)

fengjinlong avatar fengjinlong commented on May 25, 2024

干的漂亮

from blog.

yifan-blog avatar yifan-blog commented on May 25, 2024

清晰,深刻

from blog.

jackchoumine avatar jackchoumine commented on May 25, 2024
<template>
  <div v-if="show" class="border">
    <div>子组件msg:{{msg}}</div>
    <div>子组件数组:{{arr}}</div>
    <button @click="closeModel">关闭model框</button>
    <button @click="$emit('update:msg', '浪里行舟')">改变文字</button>
    <button @click="arr.push('前端工匠')">改变数组</button>
  </div>
</template>

双向绑定,这里报错啊 。

vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "showModal" is not defined on the 
instance but referenced during render. Make sure that this property is reactive, 
either in the data option, or for class-based components, by initializing the property. 
See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <Demo> at src/components/child-example/child-example.vue
       <Hello> at src/views/father-example.vue

我是从公账号里复制代码的。

from blog.

Yan2603 avatar Yan2603 commented on May 25, 2024

@ljianshu sync修饰符已经从2.x版本去掉了
方法3:使用.sync
https://cn.vuejs.org/v2/guide/migration.html#v-bind-%E7%9A%84-once%E5%92%8C-sync-%E4%BF%AE%E9%A5%B0%E7%AC%A6-%E7%A7%BB%E9%99%A4

from blog.

ljianshu avatar ljianshu commented on May 25, 2024
<template>
  <div v-if="show" class="border">
    <div>子组件msg:{{msg}}</div>
    <div>子组件数组:{{arr}}</div>
    <button @click="closeModel">关闭model框</button>
    <button @click="$emit('update:msg', '浪里行舟')">改变文字</button>
    <button @click="arr.push('前端工匠')">改变数组</button>
  </div>
</template>

双向绑定,这里报错啊 。

vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "showModal" is not defined on the 
instance but referenced during render. Make sure that this property is reactive, 
either in the data option, or for class-based components, by initializing the property. 
See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <Demo> at src/components/child-example/child-example.vue
       <Hello> at src/views/father-example.vue

我是从公账号里复制代码的。

公众号代码格式估计有问题,完整代码查看https://github.com/ljianshu/Blog/tree/master/vue2.0%E5%AD%A6%E4%B9%A0/%E5%A6%82%E4%BD%95%E5%AF%B9prop%E5%8F%8C%E5%90%91%E7%BB%91%E5%AE%9A

from blog.

ljianshu avatar ljianshu commented on May 25, 2024

@ljianshu sync修饰符已经从2.x版本去掉了
方法3:使用.sync
https://cn.vuejs.org/v2/guide/migration.html#v-bind-%E7%9A%84-once%E5%92%8C-sync-%E4%BF%AE%E9%A5%B0%E7%AC%A6-%E7%A7%BB%E9%99%A4

2.3版本强势回归了

from blog.

niusz avatar niusz commented on May 25, 2024

方法一中的父组件<props></props> 是哪种写法?怎么文档中看不到

from blog.

lwb58 avatar lwb58 commented on May 25, 2024

感谢大佬

from blog.

xiaokunxu avatar xiaokunxu commented on May 25, 2024

from blog.

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.