Compare commits

..

4 Commits

Author SHA1 Message Date
qiaopengfei 6834d27ca8 组件 2024-07-03 16:33:39 +08:00
qiaopengfei 5253a74f06 组件 2024-07-03 16:13:23 +08:00
qiaopengfei cdaa6a63d2 还原 2024-07-03 10:51:31 +08:00
qiaopengfei 7ddb64ceeb Merge pull request '全自动导入文件' (#10) from qiaopengfei into master
Reviewed-on: #10
2024-07-02 20:21:41 +08:00
3 changed files with 59 additions and 82 deletions

View File

@ -2,10 +2,8 @@
<el-input <el-input
class="ag_input" class="ag_input"
:style="{ width }" :style="{ width }"
:value="value"
:size="size"
v-on="inputListeners" v-on="inputListeners"
v-bind="[$attrs]" v-bind="attrs"
> >
<slot name="append" slot="append" /> <slot name="append" slot="append" />
<slot name="prefix" slot="prefix" /> <slot name="prefix" slot="prefix" />
@ -26,20 +24,19 @@ export default {
type: String, type: String,
default: "", default: "",
}, },
size: {
type: String,
default: "small",
},
value: {
type: String,
default: "",
},
toUpperCase: { toUpperCase: {
type: Boolean, type: Boolean,
default: false, default: true,
}, },
}, },
computed: { computed: {
attrs() {
return {
size: "small",
clearable: true, //
...this.$attrs,
};
},
// //
inputListeners() { inputListeners() {
return Object.assign( return Object.assign(

View File

@ -1,38 +1,32 @@
// 使用 require.context 自动扫描并获取 packages 目录下所有 index.js 文件的引用 // 导入组件
const requireComponent = require.context('./', true, /index\.js$/); import agInput from './agInput/index'
import agSelect from './agSelect/index'
// 定义一个数组来存储组件配置 // 组件列表
const components = requireComponent.keys().reduce((components, fileName) => { const components = [
// 排除可能的非 Vue 组件文件(这里假设所有 index.js 都是 Vue 组件) agInput,
if (fileName.endsWith('index.js')) { agSelect
const componentConfig = requireComponent(fileName).default; ]
if (componentConfig && componentConfig.name) {
components[componentConfig.name] = componentConfig;
}
}
return components;
}, {});
// 定义 install 方法,接收 Vue 作为参数 // 定义 install 方法,接收 Vue 作为参数(使用 use 注册插件,那么所有的组件都会被注册)
const install = function (Vue) { const install = function (Vue) {
if (install.installed) return; // 判断是否安装
Object.keys(components).forEach(name => { if (install.installed) return
Vue.component(name, components[name]); // 遍历注册全局组件
}); components.map(component => Vue.component(component.name, component))
install.installed = true; }
};
// 如果是在浏览器环境且全局有 Vue则自动安装 // 判断是否是直接引入文件
if (typeof window !== 'undefined' && window.Vue) { if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue); install(window.Vue)
} }
// 导出 install 方法和所有组件 export default {
export default { // 导出的对象必须具有 install才能被 Vue.use() 方法安装
// 为了方便单独引入组件,可以直接导出 components 对象 install,
...components }
}; export {
// 以下是具体的组件列表
// 注意:虽然这里导出了 components 对象,但通常不建议直接这样使用, agInput,
// 因为这样做会破坏组件的模块化封装。更常见的做法是 agSelect
// 在需要时从该文件中单独导入特定的组件。 }

View File

@ -1,22 +1,6 @@
<template> <template>
<div> <div>
<agSelect <agSelect ref="ref_Pedestal" :value="value" @input="changeInput">
ref="ref_Pedestal"
v-model="value"
@input="changeInput"
:width="'180px'"
>
<!-- <template #operate="">
<el-button
class="excel"
type="success"
icon="el-icon-download"
size="small"
plain
@click="excel()"
>导出</el-button
>
</template> -->
</agSelect> </agSelect>
</div> </div>
</template> </template>
@ -28,32 +12,34 @@ export default {
data() { data() {
return { return {
value: "", value: "",
options: { options: [{
fnSearch: this.fnSearch, value: '选项1',
formItemAttrs: { label: '黄金糕'
order_sn: { }, {
type: "input", value: '选项2',
label: "订单号", label: '双皮奶'
placeholder: "请输入订单号", }, {
}, value: '选项3',
product_category_id: { label: '蚵仔煎'
type: "select", }, {
label: "商品分类", value: '选项4',
multiple: false, label: '龙须面'
selectOpts: [{ label: "全部", value: "" }], }, {
placeholder: "选择商品分类", value: '选项5',
}, label: '北京烤鸭'
}, }],
},
}; };
}, },
methods: { methods: {
changeInput() { changeInput() {
console.log(this.value); // console.log(this.value);
}, },
}, },
}; };
</script> </script>
<style scoped lang='scss'> <style>
body {
background: #918d8d;
}
</style> </style>