Browse Source

statefulButton属性修改

wzl 1 year ago
parent
commit
e25f2d7d52

+ 1 - 1
packages/webview/src/components/CustomButton/CustomButton.vue

@@ -12,7 +12,7 @@ const { type } = item
 
 <style lang="scss">
 .custom-button {
-  width: 30px;
+  min-width: 30px;
   height: 30px;
   .img {
     display: flex;

+ 5 - 4
packages/webview/src/components/CustomButton/StatefulButton.vue

@@ -34,7 +34,6 @@ const useDocument = useDocumentStore()
 const { item } = defineProps(['item'])
 const {
   type,
-  img,
   dataElement,
   title,
   disabled,
@@ -46,8 +45,6 @@ const {
   unmount,
 } = item
 
-const isSVG = img?.trim().toLowerCase().startsWith('<svg');
-
 const NOOP = (e) => {
   e?.stopPropagation()
   e?.preventDefault()
@@ -58,8 +55,12 @@ const activeState = ref(initialState);
 const stateOptions = states[activeState.value];
 const isActive = ref(false);
 
+const { img } = stateOptions;
+const isSVG = img?.trim().toLowerCase().startsWith('<svg');
+
 const onClick = () => {
-  stateOptions.onClick(updateState, stateOptions);
+  updateState();
+  stateOptions.onClick(stateOptions);
 };
 
 const updateState = () => {