码迷,mamicode.com
首页 > 其他好文 > 详细

vue2.0学习小列子

时间:2017-09-07 19:35:08      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:css   return   family   ext   vue   ansi   set   cli   template   

参考地址:https://segmentfault.com/a/1190000006165434

例1:

<template>
<div id="app">
  <div class="main" v-cloak @click="hideTooltip">
    <div class="tooltip" v-if="show_tooltip" @click.stop>
      <input type="text" v-model="text_content">
    </div>
    <p @click.stop="toggleTooltip">{{text_content}}</p>
  </div>
</div>
</template>

<script>
/*import tab1 from ‘./components/tabs/tab1.vue‘
import tab2 from ‘./components/tabs/tab2.vue‘*/
export default {
  name: app,
  data(){
    return {
      show_tooltip:false,
      text_content:Edit me
    }
  },
  methods: {
    hideTooltip(){
      this.show_tooltip=false;
    },
    toggleTooltip(){
      this.show_tooltip=!this.show_tooltip;
    }
  }
}
</script>

<style>
*{
  padding:0;
  margin:0;
  box-sizing:border-box;
}
[v-cloak]{
  display: none;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center;
  color: #2c3e50;
  margin-top: 60px; */
  width:100%;
}
.main{
  height:300px;
  position:relative;
  padding-top: 150px;
}
.tooltip{
  position:absolute;
  left:50%;
  top:80px;
  width:290px;
  padding:10px;
  margin-left:-150px;
  border-radius: 3px;
  background-color: #5c9bb7;
}
.tooltip:after{
  content:‘‘;
  position:absolute;
  left:50%;
  width:0;
  height:0;
  bottom:-6px;
  border-left:6px solid transparent;
  border-right:6px solid transparent;
  border-top:6px solid #5190ac;
}
.tooltip input{
  border: none;
  width: 100%;
  line-height: 34px;
  border-radius: 3px;
  box-shadow: 0 2px 6px #bbb inset;
  text-align: center;
  font-size: 16px;
  font-family: inherit;
  color: #8d9395;
  font-weight: bold;
  outline: none;
}
p{
  font-size:22px;
  font-weight:bold;
  color:#6d8088;
  height: 30px;
  cursor:pointer;
  text-align: center;
}
p:before{
  content:?;
  display:inline-block;
  margin-right:5px;
  font-weight:normal;
  vertical-align: text-bottom;
}
</style>

技术分享

例2

<template>
<div id="app">
  <div id="main">
    <nav>
      <a v-for="(item,index) in items" :class="{active:item.active}" @click="makeActive(item,index)">{{item.name}}</a>
    </nav>
    <p>You chose<b>{{active}}</b></p>
  </div>
</div>
</template>

<script>
/*import tab1 from ‘./components/tabs/tab1.vue‘
import tab2 from ‘./components/tabs/tab2.vue‘*/
export default {
  name: app,
  data(){
    return {
      active:HTML,
      items:[
        {name:HTML,active:true},
        {name:CSS,active:false},
        {name:Javascript,active:false},
        {name:Vue.js,active:false}
      ]
    }
  },
  methods: {
    makeActive(item,index){
      this.active=item.name;
      for(var i=0;i<this.items.length;i++){
        this.items[i].active=false
      }
      this.items[index].active=true
    }
  }
}
</script>

<style>
*{
  padding:0;
  margin:0;
  box-sizing:border-box;
}
[v-cloak]{
  display: none;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center;
  color: #2c3e50;
  margin-top: 60px; */
  width:100%;
}
#main{
  width:432px;
  margin:0 auto;
  text-align: center;
}
nav{
  display: inline-block;
  margin:60px auto 45px;
  background-color:#5597b4;
  box-shadow:0 1px 1px #ccc;
  border-radius:2px;
}
nav a{
  display: inline-block;
  padding:18px 30px;
  color:#fff !important;
  font-weight: bold;
  font-size:16px;
  text-decoration: none;
  line-height:1;
  background-color: transparent;
  transition: background-color 0.25s;
  cursor:pointer;
}
b{
    display:inline-block;
  padding:5px 10px;
  background-color:#c4d7e0;
  border-radius:2px;
  font-size:18px;
}
.active{
  background:#ccc;
}
</style>

技术分享

例3:

 

vue2.0学习小列子

标签:css   return   family   ext   vue   ansi   set   cli   template   

原文地址:http://www.cnblogs.com/zhihou/p/7491044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!