feat: set config

This commit is contained in:
Qiuxia Fan
2022-01-06 22:30:22 +08:00
parent f19b69d050
commit e72368b6fc
10 changed files with 134 additions and 38 deletions

View File

@@ -51,6 +51,9 @@ function drawEcharts(): void {
if (!chart.value) {
return;
}
if (state.instanceChart) {
return;
}
state.instanceChart = echarts.init(chart.value, "");
unWarp(state.instanceChart).setOption(props.option);
state.instanceChart.on("click", (params: any) => {

View File

@@ -32,7 +32,7 @@ limitations under the License. -->
</el-select>
</template>
<script lang="ts" setup>
import { defineProps, ref, defineEmits } from "vue";
import { ref, defineEmits } from "vue";
import type { PropType } from "vue";
import { ElSelect, ElOption } from "element-plus";
@@ -42,21 +42,30 @@ interface Option {
}
const emit = defineEmits(["change"]);
/*global defineProps*/
const props = defineProps({
options: {
type: Array as PropType<Option[]>,
default: () => [],
},
value: { type: String, default: "" },
value: {
type: [Array, String] as PropType<string[] | string>,
default: () => [],
},
size: { type: String, default: "small" },
placeholder: { type: String, default: "Select a option" },
borderRadius: { type: Number, default: 3 },
multiple: { type: Boolean, default: false },
});
const selected = ref<string>(props.value);
const selected = ref<string[] | string>(props.value);
function changeSelected() {
if (!props.multiple) {
return;
}
const options = props.options.filter((d: Option) =>
selected.value.includes(d.value)
props.multiple
? selected.value.includes(d.value)
: selected.value === d.value
);
emit("change", options);
}