When we copied the code on layui, and referenced layui.css, and layui.all.js. However, the corresponding effect is still not displayed.
Please see if your js code is at the end.
js code is as follows:
<script> //Demo layui.use('form', function(){ var form = layui.form; //Copied from the document does not seem to have this sentence form.render(); //listen for submission form.on('submit(formDemo)', function(data){ layer.msg(JSON.stringify(data.field)); return false; }); }); </script>
Be sure to put this code at the end to load the desired effect .
Of course, if you want to put js in any position, you can do this (in any case, you just need to execute the above js code at the end)
Choose one of the following two methods, one is native js, the other is jq
<script> //Native js implementation window.onload = function(){ } //jq implementation, of course, the premise is that you import the jq file $(function(){ }); </script>