Note After npm download layui import is invalid
First, the entire package into Vue layui the public folder
Layui introduced in index.html public folder in
<link rel="stylesheet" href="./layui/css/layui.css">
<script src="./layui/layui.js"></script>
Then use layui after the dom loaded in vue file
export default {
name: 'app',
components: {
HelloWorld
},
mounted () {
layui.use('form', function () {
var form = layui.form;
form.on('submit(demo1)', function (data) {
layer.alert(JSON.stringify(data.field), {
title: '最终的提交信息'
})
return false;
});
});
}
}