$import("inc/checkform.js","js","checkform")

本文解释了一个JavaScript代码片段中$import()函数的作用及如何在HTML页面中使用该函数来加载外部JavaScript文件。$import()函数用于动态加载外部资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script language="javascript">$import("inc/checkform.js","js","checkform");</script>看不懂

2011-07-03 09:39 高手之烟花易冷  |  浏览 622 次
忘哪位高手详细讲解一下什么意思,看不懂,另$是什么什么意思?谢谢
2011-07-03 10:14 提问者采纳
不好意思,详细不了!
这就是一个JS代码!
嵌入html,然后执行一个函数!
$import("inc/checkform.js","js","checkform");
$import 函数名 后面是参数
提问者评价
哦,我看错了!呵呵,。。。还是谢谢。。。。
评论  |  0  0

书风笑 | 来自团队:web钱端开发 | 六级 采纳率46%

擅长: 其他编程语言 Html/Css Html/Css JavaScript 网站使用

业务画面:<template> <my-form ref="forRef" :model="data"> <my-form-item label="产品名称" prop="name"> <my-input v-model="data.name" :rules="[ { required: true, message: '请输入产品名称', trigger: 'blur' }, { max: 10, maxMessage: '产品名称不能超过10个汉字' } ]" /> </my-form-item> <my-form-item label="产品描述" prop="age"> <my-input v-model="data.age" :rules="[ { required: true, message: '请输入产品描述', trigger: 'blur' }, { max: 10, maxMessage: '姓名不能超过200个汉字' } ]" /> </my-form-item> <my-form-item label="性别" prop="sex" :rules="[{ required: true, message: '请选择性别', trigger: 'change' },]"> <my-select v-model="data.sex"> <my-option v-for="item in sexOptions" :label="item.lable" :value="item.value" /> </my-select> </my-form-item> <my-form-item label="产品单价" prop="price"> <my-input v-model="data.price" :rules="[ { required: true, message: '请输入产品单价', trigger: 'blur' }, { min: 0, message: '产品单价不能小于0', trigger: 'blur' }, { max: 10000, message: '产品单价不能超过10000', trigger: 'blur' } ]" /> </my-form-item> <my-form-item label="产品库存" prop="stock"> <my-input v-model="data.stock" :rules="[ { required: true, message: '请输入产品库存', trigger: 'blur' }, { min: 0, message: '产品库存不能小于0', trigger: 'blur' }, { max: 10000, message: '产品库存不能超过10000', trigger: 'blur' } ]" /> </my-form-item> <my-form-item label="生产厂家" prop="manufacturer"> <my-input v-model="data.manufacturer" :rules="[ { required: true, message: '请输入生产厂家', trigger: 'blur' }, ]" /> </my-form-item> </my-form> {{ data }} <button @click="checkForm">提交</button> <button @click="clearForm">清空</button> </template> <script setup> import myForm from '@/components/myForm'; import myFormItem from '@/components/myForm/myFormItem'; import MyInput from '@/components/input'; import MySelect from '@/components/mySelect'; import MyOption from '@/components/mySelect/myOption'; const forRef = ref() const sexOptions = reactive([{ lable: "男", value: 1 }, { lable: "女", value: 2 }]) const data = reactive({ name: "", age: "", sex: "", price: "", stock: "", manufacturer: "", formCheck: null }) function checkForm() { data.formCheck = forRef.value.validate() } function clearForm() { forRef.value.resetField() } const rules = reactive({ name: [ { required: true, message: '请输入产品名称', trigger: 'blur' }, { max: 10, message: '长度超过10位', trigger: 'blur' }, ], description: [ { required: true, message: '请输入产品描述', trigger: 'blur' }, { max: 200, message: '长度超过200位', trigger: 'blur' }, ], category: [ { required: true, message: '请选择产品分类', trigger: 'change' }, ], }); </script> select:<template> <div class="select"> <button class="trigger" @click="toggleMenu"> {{ selectedLabel || placeholder }} <span class="arrow" :class="{ 'rotated': isOpen }">▼</span> </button> <div class="menu" :class="{ 'menu_open': isOpen }"> <template v-for="item in selectOptions"> <div class="option" @click="handleClick(item)" :class="{ 'selected': item.selected }"> <span>{{ item.label }}</span> <!-- <span class="left-content">{{ item.label }}</span> --> </div> </template> </div> </div> <slot></slot> </template> <script setup> const model = defineModel() const selectedLabel = ref('') const selectOptions = ref([]) const isOpen = ref(false) const props = defineProps({ placeholder: { type: String, default: '请选择' }, options: { type: Array, default: [] } }) const emit = defineEmits(['change']) function handleClick(item) { model.value = item.value toggleMenu() } function setOtherOptionDefault(value) { selectOptions.value.forEach(item => { if (item.value != value) { item.selected = false } else { item.selected = true } }) } function toggleMenu() { isOpen.value = !isOpen.value } provide('pushOptions', item => { selectOptions.value.push(item) }) watch( () => model, // 监听的属性 (newVal, oldVal) => { // 变化时的回调函数 if (newVal != null && newVal != undefined && newVal.value != null && newVal.value != undefined) { selectOptions.value.forEach(item => { if (item.value == newVal.value) { selectedLabel.value = item.label setOtherOptionDefault(newVal.value) } }) } else { selectedLabel.value = "" } }, { deep: true } ); onMounted(() => { if (props.options.length > 0) { selectOptions.value = props.options } selectOptions.value.forEach(item => { if (item.value == model.value) { selectedLabel.value = item.label setOtherOptionDefault(model.value) } }) }) </script> <style scoped lang="scss"> .option { width: 100%; padding: 3px 0px 3px 0px; &:hover { background-color: #fa0808; } span { margin-left: 15px; font-size: 14px; user-select: none; } } .selected { color: #409eff; } .select { position: relative; width: 200px; } .trigger { width: 100%; padding: 8px 12px; border: 1px solid #ccc; background-color: #fff; text-align: left; cursor: pointer; } .arrow { float: right; transition: transform 0.3s ease; } .arrow.rotated { transform: rotate(180deg); } .menu { position: absolute; top: 100%; left: 0; width: calc(100% - 1px); height: 0px; overflow-x: auto !important; overflow-y: auto !important; border: 1px solid #ccc; border-top: none; background: white; z-index: 10; transition: height 0.3s ease; &::-webkit-scrollbar { width: 5px; /* 垂直滚动条宽度 */ height: 5px; /* 水平滚动条高度(可选) */ } /* 滚动条滑块部分 */ &::-webkit-scrollbar-thumb { background-color: rgba(0, 0, 0, 0.3); border-radius: 4px; } /* 滚动条轨道 */ &::-webkit-scrollbar-track { background-color: #f1f1f1; } } .menu.menu_open { height: 100px !important; } .fade-enter-active, .fade-leave-active { transition: opacity 0.2s; } .fade-enter-from, .fade-leave-to { opacity: 0; } </style> 子组件:<template> </template> <script setup> const props = defineProps({ label: { type: String, required: true }, value: { type: [String, Number], required: true }, }) const pushOptions = inject('pushOptions') onMounted(() => { pushOptions && pushOptions({ value: props.value, label: props.label, selected: false },) }) </script> 我想像验证输入框一样判断下拉框是否选择
最新发布
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值