Giter VIP home page Giter VIP logo

vue-practice's Introduction

vue-practice

  • 算出プロパティはリアクティブな依存関係にもとづきキャッシュされる
  • リアクティブな依存関係が更新されたときにだけ再評価される
  • 実行の度に現在時刻を返すなどの場合はメソッドを使うのが望ましい
  • メソッド呼び出しは再描画が起こると常に関数を実行する
  • キャッシングの必要がないかつ、巨大な配列をループしたり多くの計算を必要とする場合はcomputedを使う。

イベントについて

<!-- クリックイベントのバブリングをしない -->
<a v-on:click.stop="doThis"></a>

<!-- submitイベントで画面遷移しない -->
<form v-on:submit.prevent="onSubmit"></form>

<!-- 修飾子は繋げて書ける -->
<a v-on:click.stop.prevent="doThat"></a>

<!-- 値を指定せず修飾子だけの指定が可能 -->
<form v-on:submit.prevent></form>

<!-- キャプチャリングを使用する。内部要素を対象とするイベントはその要素によって処理される前にここで処理される -->
<div v-on:click.capture="doThis"></div>

<!-- event.targetが要素自身のときだけイベントハンドラが呼び出される。子要素の時は呼び出されない。 -->
<div v-on:click.self="doThat"></div>

コンポーネント

DOM上で直接コンポーネントを使用する場合の命名は W3C rules に従ったカスタムタグ名(小文字のチェーンケース)を推奨

Vue.component('sample-a', {/*...*/});
Vue.component('sample-b', {/*...*/});
Vue.component('sample-c', {/*...*/});
// これらは全てグローバルに定義されているため定義後に作成された全てのVueインスタンスのテンプレート内で使用できる
new Vue({el: "#app"})
<div id="app">
    <sample-a></sample-a>
    <sample-b></sample-b>
    <sample-c></sample-c>
</div>

ローカルとして定義する場合

const componentA = {/*...*/}
const componentB = {/*...*/}
const componentC = {/*...*/}
new Vue({
  el: '#app',
  components: {
    'component-a': componentA,
    'component-b': componentB,
    'component-c': componentC,
  }
})

https://jp.vuejs.org/v2/guide/components-registration.html#%E5%9F%BA%E5%BA%95%E3%82%B3%E3%83%B3%E3%83%9D%E3%83%BC%E3%83%8D%E3%83%B3%E3%83%88%E3%81%AE%E8%87%AA%E5%8B%95%E3%82%B0%E3%83%AD%E3%83%BC%E3%83%90%E3%83%AB%E7%99%BB%E9%8C%B2

vue-practice's People

Contributors

m1y474 avatar

Watchers

 avatar

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.