zoukankan      html  css  js  c++  java
  • vue 3.0 项目搭建移动端 (七) 安装Vant

    # 通过 npm 安装 

    npm i vant -S

    安装完配置

    babel.config.js

    module.exports = {
      presets: ['@vue/app'],
      plugins: [
        'lodash',
        [
          'import',
          {
            libraryName: 'vant',
            libraryDirectory: 'es',
            style: true
          },
          'vant'
        ]
      ]
    };

    运行后报错

     先安装插件

    # 安装 babel-plugin-import 插件
    npm i babel-plugin-import -D

    再次运行,但是这里配置了‘lodash',如果去掉可以正常运行,如果不去掉,还要添加

    npm i lodash -D
    npm i babel-plugin-lodash -D

    然后再运行 OK

    <template>
      <van-tabbar v-model="active" style="z-index: 1999">
        <van-tabbar-item v-for="(tab, index) in tabbar" :dot="tab.dot" :info="tab.info" :key="index">
          <span>{{tab.name}}</span>
          <div slot="icon">
            <p class="icon-box"></p>
          </div>
        </van-tabbar-item>
      </van-tabbar>
    </template>
    <script>
    import { Tabbar, TabbarItem } from "vant";
    export default {
      data() {
        return {
          active: 0,
          tabbar: [
            {
              name: "首页",
              path: "/",
              pathName: "home",
              dot: false,
              info: "",
              code: "4"
            },
            {
              name: "其它",
              path: "/",
              pathName: "home",
              dot: false,
              info: "",
              code: "4"
            }
          ]
        };
      },
      created() {},
      mounted() {},
      watch: {},
      computed: {},
      methods: {},
      components: {
        [Tabbar.name]: Tabbar,
        [TabbarItem.name]: TabbarItem
      }
    };
    </script>
    <style lang="scss" scoped>
    .van-tabbar-item__icon {
      .icon-box {
        width: 24px;
        height: 24px;
        img {
          max-width: 100%;
          width: 100%;
          height: 100%;
          margin: 0 auto;
        }
      }
    }
    </style>
  • 相关阅读:
    java.net.BindException: Address already in use: bind
    修改Oracle 10g Express Edition默认的8080端口
    五虎
    easily add files to META-INF in NetBeans
    http://edu.makery.ch/
    JavaFX 2 Dialogs
    JavaFx版本植物大战僵尸
    CSS样式表——布局练习(制作360网页)
    CSS样式表
    CSS样式表——超链接样式
  • 原文地址:https://www.cnblogs.com/dianzan/p/12373480.html
Copyright © 2011-2022 走看看