Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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 class="container">
      <img :src="src" />
      <h1>{{title}}</h1>
    </div>

    <div class="container">
      <div class="option">
        <!-- 若不是第一天就顯示 -->
        <!-- index != 0 -->
        <a v-if="index > 0" href="#" @click.prevent="changePage(-1) ">
          <i class="fas fa-caret-left fa-3x"></i>
        </a>
        <div class="optionTitle">
          <span class="number">{{index+1 }}</span>
          <span class="type">{{today.type}}</span>
          <span class="title">{{today.title}}</span>
          <a :href="today.link"></a>
        </div>
        <!-- 若不是最後一天就顯示 -->
        <!-- index != this.menu.length -->
        <a v-if="index < total -1" href="#" @click.prevent="changePage(1)">
          <i class="fas fa-caret-right fa-3x"></i>
        </a>
      </div>
    </div>
  </div>
              
            
!

CSS

              
                body {
  background-color: #263238;
}

.container {
  width: 960px;
  margin: 0 auto;

  img {
    width: 100%;
    margin-top: 5%;
  }

  h1 {
    text-align: center;
    padding: 3% 0;
    font-size: 42px;
    color: #fff;
  }

  .option {
    background-color: #eeeeee;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1%;
    border-radius: 100px;
  }

  .optionTitle {
    width: 95%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 28px;

    .number,
    .type,
    .title {
      padding: 0 1%;
      color: #263238;
      font-weight: bold;
    }
  }
  .fas {
    color: #263238;
    padding: 0 10%;
    &:hover{
      color: #757575;
    }
  }
}
              
            
!

JS

              
                let data = {
  title: "Practice Vue With Alex",
  src:
    "https://images.unsplash.com/photo-1593642634315-48f5414c3ad9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80",
  index: 0,
  menu: [
    {
      type: "練習一",
      title: "選單事件綁定",
      link: "#",
    },
    {
      type: "練習二",
      title: "雙向資料表單處理",
      link: "#",
    },
    {
      type: "練習三",
      title: "使用者輸入呈現",
      link: "#",
    },
    {
      type: "練習四",
      title: "篩選資料轉換",
      link: "#",
    },
    {
      type: "練習五",
      title: "互動式資料選單",
      link: "#",
    },
    {
      type: "練習六",
      title: "CSS + jQuery 動畫",
      link: "#",
    },
    {
      type: "練習七",
      title: "資料觀測與設定",
      link: "#",
    },
    {
      type: "練習八",
      title: "家鄉通訊錄 API",
      link: "#",
    },
    {
      type: "練習九",
      title: "TodoList 實做",
      link: "#",
    },
  ],
};
var vm = new Vue({
  el: "#app",
  data: data,
  methods: {
    changePage(change) {
      this.index = (this.index + change + this.total) % this.total;
      // this.index += change;
      // if (this.index < 0) {
      // 	this.index = 0;
      // } else if (this.index > changePage -1) {
      // 	this.index = changePage - 1;
      // }
    },
  },
  computed: {
    //重複的變數
    today() {
      return this.menu[this.index];
    },
    total() {
      return this.menu.length;
    },
  },
});

              
            
!
999px

Console