Vue Mobile Bullet Box Assembly

Source: Internet
Author: User

Recently do a mobile project, the box to write more trouble, find the data, found this component, but the document is relatively small, their own research, the mistake I encountered, and the detailed usage to share to everyone! In doubt can open the component to see, this component is imitation layer-mobile, many uses are the same, can see Oh!

First, NPM installation

Current version 1.2.0 NPM install vue-layer-mobile//If you have problems with the new version, you can go back to the old npm install [email protected]

Second, adjust the configuration: Because this component has woff,ttf,eto,svg type files, so to configure some loader,

Configure the following in Webpack.config.js, first install Url-loader and file-loader:{test:/\.woff$/, loader: "url-loader?limit=10000& Mimetype=application/font-woff "},{test:/\.ttf$/, loader:" url-loader?limit=10000&mimetype=application/ Octet-stream "},{test:/\.eot$/, Loader:" File-loader "},{test:/\.svg$/, loader:" Url-loader?limit=10000&mimetype =image/svg+xml "}

Iii. Introduction and use

Import ' vue-layer-mobile/need/layer.css ' import layer from ' vue-layer-mobile ' vue.use (layer)

Iv. Specific Use Introduction:--this component has a total of 6 methods, not completely imitation layer-mobile, some simple frame is still very useful.

     Toast: Text and icons: Testlayertoast () {this. $layer. Toast ({  icon:  ' I            Con-check ', //  icon clssname  if the empty  toast position is below, otherwise center     content:  ' hint text ',   time: 2000 //  Auto-Vanishing time  toast type default vanishing time is 2000 milliseconds  })},//            Loading:testlayerloading1 () {var _this = this;            this. $layer. Loading (' Loading ... ');            SetTimeout (function () {_this. $layer. Close ();        },3000); },///Dialog:testlayerdialog () {this. $layer. dialog ({  title: [' it's the title ',   ' background:red; '], //  The first one is the title content    The second is the style of the title bar (can be empty)     content:   ' This is content ',   contentClass:  ' className ',   btn: [' Cancel ', ' OK '],//   time: 2000})// If there is btn  then (function  (res) {  // res 0 o'clock is the user clicked on the left    for 1 o'clock the user clicked on the right &nbs            P   let position = res === 0 ?  ' left '  :  ' right '  &nbs P; console.log (position)  })},//Footer:testlayerfooter () {this. $l             Ayer.footer ({  content:  ' This is content ',   btn: [' Cancel ',  ' option 1 ',  ' option 2 '] })//  if there is btn . Then (function  (res) {  var text&        nbsp;= res==0 ?  ' Cancel '  :  ' option ' +res   console.log (Text)}}, Open Testlayeropen () {this. $layer. Open ({style: ' Border:none; background-color:# 78ba32; Color: #fff; ', Content: ' Contents '})},//close Testlayerclose () {var _ This = this;            this. $layer. Loading (' Test shutdown method ');            SetTimeout (function () {_this. $layer. Close ();        },3000); }

Several effects show:

Vue Mobile Bullet Box Assembly

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.