Image.tsx 700 B

1234567891011121314151617181920212223242526272829
  1. import { defineComponent } from "vue";
  2. import { string } from "vue-types";
  3. import { useEditor } from "../../..";
  4. import { View } from "./View";
  5. const imgDef = require("@/assets/imgs/default.png");
  6. export const Image = defineComponent({
  7. props: {
  8. value: string(),
  9. },
  10. emits: ["update:value"],
  11. setup(props, { emit }) {
  12. const { store } = useEditor();
  13. async function changeVal() {
  14. alert("选择模型");
  15. emit("update:value", Math.random().toString());
  16. }
  17. return () => (
  18. <View>
  19. <img
  20. class="w-1/1 h-1/1"
  21. src={props.value || imgDef}
  22. onClick={store.isEditMode? changeVal : undefined}
  23. />
  24. </View>
  25. );
  26. },
  27. });