SOURCE

const str = `<u-form-item label="姓名" prop="studentName" required><u-input v-model="form.studentName" /></u-form-item>
			<u-form-item label="所报班级" prop="className" required><u-input v-model="form.className" :disabled="true" /></u-form-item>
			<u-form-item label="性别" prop="gender" required><Picker :list="genderList" :value.sync="form.gender" /></u-form-item>
			<u-form-item label="身份证号" prop="idCard" required><u-input v-model="form.idCard" /></u-form-item>
			<u-form-item label="身份证正面照片" prop="idCardFront" label-width="150" required><upload-img :urls.sync="form.idCardFront" /></u-form-item>
			<u-form-item label="身份证反面照片" prop="idCardReverse" label-width="150" required><upload-img :urls.sync="form.idCardReverse" /></u-form-item>
			<u-form-item label="工作单位" prop="unitName" required><u-input v-model="form.unitName" /></u-form-item>
			<u-form-item label="职务" prop="position" required><u-input v-model="form.position" /></u-form-item>
			<u-form-item label="最高学历" prop="education" required><u-input v-model="form.education" /></u-form-item>
			<u-form-item label="通讯地址(需要邮寄录取通知书,务必准确)" prop="address" required><u-input v-model="form.address" /></u-form-item>
			<u-form-item label="主要学习经历" prop="learningExperience" required><u-input v-model="form.learningExperience" /></u-form-item>
			<u-form-item label="主要工作经历" prop="workExperience" required><u-input v-model="form.workExperience" /></u-form-item>
			<u-form-item label="从什么渠道了解到招生信息?" prop="joinWay" label-width="150" required><Picker :list="joinWayList" :value.sync="form.joinWay" /></u-form-item>
			<u-form-item label="哪些因素吸引您过来" label-width="150" prop="interestedId" required><CheckboxGroup :value.sync="form.interestedId" :options="interestedList" /></u-form-item>
			<u-form-item label="高研学习的目的与期待" prop="objective" required><u-input v-model="form.objective" /></u-form-item>
			<u-form-item label="近期美术作品" prop="artworkUrl" label-width="150" required><upload-img :urls.sync="form.artworkUrl" /></u-form-item>
			<u-form-item label="第一联系人电话" prop="contactPhone" required><u-input v-model="form.contactPhone" /></u-form-item>
			<u-form-item label="第二联系人电话" prop="secondaryContact" required><u-input v-model="form.secondaryContact" /></u-form-item>
			<u-form-item label="邮箱" prop="email" required><u-input v-model="form.email" /></u-form-item>`

const reg = /\s*[^=\s+]+\s*=\s*([^=>]+)?(?=(\s+|>))/g

const result = str.match(reg)

// console.log(result)

const list = []

result.forEach(item => {
    if(item.indexOf('prop') !== -1) {
        const rega = /(?<=(prop=")).*(?=("))/
        const [str] = item.match(rega)
        list.push(str)
    }
})

const formList = str.split('\n');

const finalFormList = []

formList.forEach((item, index) => {
    const form = `<template v-if="visibleFields.includes('${list[index]}')">${item}</template>`
    finalFormList.push(form)
})
console.log(finalFormList.join(''))
console 命令行工具 X clear

                    
>
console