Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app">
  <!-- 頁籤按鈕 -->
  <div>
    <button
      @click="changeTab('tab1')">
      頁籤1
    </button>
    <button
      @click="changeTab('tab2')">
      頁籤2
    </button>
  </div>
  <!-- 表單內容 -->
  <div
    :is="currentTab"
    :tab-data="currentTabData">
  </div>
  <!-- 檢視JSON資料 -->
  <hr></hr>
  <div>表單JSON:</div>
  <pre>{{form}}</pre>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                Vue.component('tab1', {
  template: `
  <div>
    <div>
      頁籤1欄位1
      <input
        type="text"
        v-model="tabData.column1">
    </div>
    <div>
      頁籤1欄位2
      <input
        type="text"
        v-model="tabData.column2">
    </div>
    <div>
      頁籤1欄位3
      <input
        type="text"
        v-model="tabData.column3">
    </div>
    <div>
      頁籤1欄位4
      <input
        type="text"
        v-model="tabData.column4">
    </div>
    <div>
      頁籤1欄位5
      <input
        type="text"
        v-model="tabData.column5">
    </div>
  </div>
  `,
  props: ['tabData'],
})

Vue.component('tab2', {
  template: `
  <div>
    <div>
      頁籤2欄位1
      <input
        type="text"
        v-model="tabData.column1">
    </div>
    <div>
      頁籤2欄位2
      <input
        type="text"
        v-model="tabData.column2">
    </div>
    <div>
      頁籤2欄位3
      <input
        type="text"
        v-model="tabData.column3">
    </div>
    <div>
      頁籤2欄位4
      <input
        type="text"
        v-model="tabData.column4">
    </div>
    <div>
      頁籤2欄位5
      <input
        type="text"
        v-model="tabData.column5">
    </div>
  </div>
  `,
  props: ['tabData'],
})


const vm = new Vue({
  el: '#app',
  data: {
    // 目前頁籤使用的component名稱
    currentTab: 'tab1',
    // 表單資料
    form: {
      // 頁籤1
      tab1: {
        column1: '',
        column2: '',
        column3: '',
        column4: '',
        column5: '',
      },
      // 頁籤2
      tab2: {
        column1: '',
        column2: '',
        column3: '',
        column4: '',
        column5: '',
      }
    }
  },
  computed: {
    // 目前的頁籤資資料
    currentTabData () {
      return this.form[this.currentTab] // tab1 or tab2
    }
  },
  methods: {
    // 切換頁籤
    changeTab (name) {
      this.currentTab = name
    }
  }
})
              
            
!
999px

Console