Using the Layer.js pop-up layer plugin in Vue

Source: Internet
Author: User

Layer.js (mobile) is a small, easy-to-use pop-up layer plug-in that was used extensively in previous Apicloud projects, but was recently bored with Apicloud's IDE, very unfriendly documentation, and very low development efficiency, and decided to discard and turn to Vue for development. There was trouble introducing layer.js during the development process. The reason is that layer.js does not support import imports, then you need to modify its source code. After looking at its source code, found that there are only two places to modify,

A global variable layer has been exposed in the source code, so just add it at the end of the script

default layer;

This means that the global variable is exported.

Then find the following code in the file comment out, this code is to add style for layer, but the use of the wrong path, it is not much help.

Document.head.appendChild (function() {    var link = doc.createelement (' link ');     = path + ' need/layer.css?2.0 ';     = ' Text/css ';     = ' StyleSheet ' link.id = ' layermcss ';     return link;} ());

Next put Layer.js and layer.css into Static/js and static/css respectively, where needed, such as component internal or global registration, because the project will be used in many places, so the use of global registration, in the Main.js

Import layer from '. /static/js/layer.js '

LAYER.CSS also uses global registration, which can be introduced via link in index.html, and can be placed in App.vue

<!--index.html -<Linkrel= "stylesheet"href= "./static/css/layer.css" /><!--or -<!--App.vue -<style>@import ". /static/css/layer.css ";</style>

The next step is to use Layer.open and other methods in each component.

This should work for a variety of scripts that do not support import imports, that is, the module that is not provided by NPM.

Using the Layer.js pop-up layer plugin in Vue

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.