<template>
  <left-skeleton @save="save" @deleteFunc="deleteFunc">
    <el-form :model="form">
      <el-form-item label="按钮名称">
        <el-input v-model="form.name" placeholder="请输入按钮名称"/>
      </el-form-item>
      <el-form-item label="api">
        <el-input v-model="form.api" placeholder="请输入按钮调用api" />
      </el-form-item>
    </el-form>
  </left-skeleton>
</template>

<script setup>
import { defineProps, inject, ref } from 'vue';
import leftSkeleton from '../H5Editor/leftSkeleton.vue';

const saveComponents = inject('saveComponents');
const deleteItemComponents = inject('deleteItemComponents');

const props = defineProps({
  item: Object,
});


const form = ref({
    name: props.item.item.text || "",
    api: props.item.item.api || "",
});

const save = () => {
  saveComponents('保存');
};

const deleteFunc = () => {
  /**
   * 1.删除本地
   * 2.删除远程
   */
  deleteItemComponents(props.item);
};

console.log(form.value,props.item);
</script>

<style scoped>
.upload-demo {
  margin-top: 1em;
}
</style>
