Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <div id="app">
    <!-- 傳入參數值 -->
    <my-component 
      :message="message"
      :name="name">
    </my-component>
  </div>
  
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
</body>
</html>
 
Vue.component('MyComponent', {
  template: '<div class="component">{{message}} {{name}} </div>',
  props: {
    message: {
      type: String,      // 型態
      default: "Hello",  // 預設值
    },
    name: {
      type: String,      // 型態
      required: true,    // 是否必填
    }
  },
})
var vm = new Vue({
  el: '#app',
  data: {
    message: 'Hi',
    name: 'Kanboo'
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers