赞
踩
html部分
- <form class="layui-form">
- <div class="layui-form-item" v-for="item,index in data" :key="index">
- <div class="layui-form-item title">
- <label class="layui-form-label">标题</label>
- <div class="layui-input-inline">
- <input type="text" name="title[]" placeholder="" :value="item.title" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">图片路径</label>
- <div class="layui-input-inline">
- <input type="text" name="file[]" placeholder="" :value="item.file" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item content">
- <label class="layui-form-label">内容</label>
- <div class="layui-input-block" style="width:600px;">
- <script :id="item.filename" name="content[]" style="height: 300px" type="text/plain">{{item.content}}</script>
- </div>
- </div>
- </div>
- <div class="layui-form-item">
- <div class="layui-input-block">
- <button class="layui-btn" lay-submit="" lay-filter="submit" id="Action" @click="add()">提交保存</button>
- </div>
- </div>
- </form>
js部分
- data(){
- return{
- data:[],
- //记录实例化百度编辑器
- edit:{},
- }
- },
- //根据data中的数据动态渲染编辑器
- setTimeout(()=>{
- for(i in this.data){
- this.edit[i] = UE.getEditor(this.data[i].filename+'');
- }
- },300);
-
-
- add(){
- layui.use('form',()=>{
- var form = layui.form,
- $ = layui.jquery;
-
- form.on('submit(submit)', (data) => {
- let edit = this.edit;
- for(i in edit){
- //循环获取内容
- console.log(edit[i].body.innerHTML);
- }
-
- return false;
- });
- })
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。