useState.js 455B

12345678910111213141516171819202122232425262728293031
  1. import { reactive } from 'vue'
  2. export function useState() {
  3. const state = reactive({
  4. disable: true,
  5. label: 'Ubah',
  6. icon: 'pi pi-pencil',
  7. })
  8. function setState() {
  9. if (state.disable) {
  10. state.label = 'Simpan'
  11. state.icon = 'pi pi-check'
  12. state.disable = false
  13. } else {
  14. state.label = 'Ubah'
  15. state.icon = 'pi pi-pencil'
  16. state.disable = true
  17. }
  18. }
  19. return {
  20. state,
  21. setState,
  22. }
  23. }