Home > Article > Web Front-end > How to configure mint-ui using Vue2.0
This time I will show you how to use Vue2.0 to configure mint-ui, and what are the precautions for using Vue2.0 to configure mint-ui. The following is a practical case, let's take a look.
Recently, I have gradually adopted the vue.js mint-ui technology stack when developing projects. However, when I startedconfiguring the development environment yesterday, I encountered various errors, even if I followed the two companies’ The official document configuration will still report errors. I went back to configure it after get off work all night before finally configuring it, so I recorded it to prevent it from happening again later. .
Introduction to vue.js
Vue.js is a tool for creating web interactive interfaces. Its characteristics areexpressions and calculated properties.
mint-ui introduction
Mint UI is based on the open source of the Ele.me front-end team The features of Vue.js’s mobile component library are:Create Vue.js project
First create it locally according to the method given by vue official website A vue project# 全局安装 vue-cli $ npm install --global vue-cli # 创建一个基于 webpack 模板的新项目 $ vue init webpack my-project # 安装依赖,走你 $ cd my-project $ npm install $ npm run dev
Configure the Mint UI environment
Then introduce the Mint UI environment into the project according to the official website of Mint UInpm i mint-ui -SThen in the project The main.js file in introduces all components
import Vue from 'vue' import MintUI from 'mint-ui' import 'mint-ui/lib/style.css' import App from './App.vue' Vue.use(MintUI)Okay, according to the official website, the above code completes the introduction of Mint UI.
Run the project
Finally, write a button component in APP.vue according to the content of the official website and take a look<template> <p id="app"> <mt-button @click.native="handleClick">按钮</mt-button> </p> </template> <script> export default{ el: '#app', methods: { handleClick: function() { this.$toast('Hello world!'); } } } </script> <style> </style>Okay, the environment is set up. Let’s run the project
npm run devand then report various errors
solve the errors
First You need to install the CSS interpreter in your local projectnpm i css-loader style-loader -D
{ test: /\.css$/, include: [ /src/, '/node_modules/mint-ui/lib/' ], use:[ {loader:"style-loader"}, {loader:"css-loader"}, ] }If you report an error such as es2015, you need to modify the .babelrc file to:
{ "presets": [ ["es2015", { "modules": false }] ], "plugins": [["component", [ { "libraryName": "mint-ui", "style": true } ]]] }
Finally run
After the environment is configured, we finally run it.npm run dev
How to use JS to obtain the absolute position of DOM elements
How to perform vue.js login control
The above is the detailed content of How to configure mint-ui using Vue2.0. For more information, please follow other related articles on the PHP Chinese website!