用vue写手机端网页代码怎么优化?

想尝试用vue写个网站,但是代码写的很low,很像h5,求大神指教怎么写,怎么优化。这是我的代码


<template>

  <div class="head">

      <div class="logo">

        <img src="@/assets/logo.png" alt="">

      </div>

      <div class="menu">

        <img src="@/assets/menu.png" alt="">

      </div>

  </div>

</template>


<script>

export default {

  name: 'Header',

  data () {

    return {

      msg: '你好'

    }

  }

}

</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->

<style scoped>

.head{

  width: 100%;

  height: 1.5rem;

  background-color:antiquewhite;

  position:relative;

}

.logo{

  width: 4rem;

  height: 1.1rem;

  background-color: aquamarine;

  position: absolute;

  top:.2rem;

  left: .2rem;

}

.logo img{

  width: 100%;

  height: 100%;

}

.menu{

  width: 1rem;

  height: 1.1rem;

  background-color: azure;

  position: absolute;

  top: .2rem;

  right: .2rem;

}

.menu img{

  width: 100%;

}

</style>


一只名叫tom的猫
浏览 718回答 1
1回答

幕布斯7119047

&nbsp; <div class="logo">&nbsp; &nbsp; <img :src="logo" alt="">&nbsp; </div>&nbsp; <div class="menu" v-on:click="isShow=!isShow">&nbsp; &nbsp; <img :src="menu" alt="">&nbsp; </div>&nbsp; <ul v-show="isShow">&nbsp; &nbsp; <li>首页</li>&nbsp; &nbsp; <li>服务项目</li>&nbsp; &nbsp; <li>公司案例</li>&nbsp; &nbsp; <li>新闻动态</li>&nbsp; &nbsp; <li>关于我们</li>&nbsp; </ul></div></template><script>export default {name: 'Header',data () {return {&nbsp; msg: '你好',&nbsp; isShow:false,&nbsp; logo:require("@/assets/logo.png"),&nbsp; menu:require("@/assets/menu.png")}},这样写比之前简单了很多
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript