Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vm.$mountの説明について #3

Open
hiro0218 opened this issue Jan 23, 2019 · 1 comment
Open

vm.$mountの説明について #3

hiro0218 opened this issue Jan 23, 2019 · 1 comment
Assignees

Comments

@hiro0218
Copy link
Member

hiro0218 commented Jan 23, 2019

マウントの仕方で elvm.$mount がありますが、本稿では基本的にvm.$mountで進められています。
elの説明も織り交ぜておいたほうが初学者は混乱しないかと思いました。

el

https://jp.vuejs.org/v2/api/#el

  • 制約: new 経由でインスタンス作成のみだけ
  • 公式のガイドには、elでのマウントが最初に出てくる
var app = new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue!'
  }
})

vm.$mount()

https://jp.vuejs.org/v2/api/#vm-mount

  • アンマウントな Vue インスタンスのマウンティングでの利用
var MyComponent = Vue.extend({
  template: '<div>Hello!</div>'
})

new MyComponent().$mount('#app')
@hiro0218 hiro0218 added the WIP Work in progress label Jan 23, 2019
@hiro0218 hiro0218 removed the WIP Work in progress label Jan 23, 2019
@mjcreativelab
Copy link
Contributor

わかりました!

cli 使うと普通に vm.$mount() でテンプレート組まれるので、基本は vm.$mount() として、 el は口頭で補足する形にできればと思います!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants