Skip to content

Beta

Các component App Bridge này còn mới và chưa được kiểm thử trong Shopify admin thật. Trong giai đoạn beta, API có thể thay đổi ở bản phát hành minor. Nếu có gì không hoạt động, hãy mở issue.

SaveBar ​

Trước khi bắt đầu, xem Cài đặt; về open, xem Modal.

SaveBar render ui-save-bar. Như type của ui-save-bar mô tả, "the button with variant primary is the Save button and the button without a variant is the Discard button":

vue
<script setup lang="ts">
import { ref } from 'vue'
import { SaveBar } from 'polaris-vue-elements/app-bridge'

const dirty = ref(false)

function save(): void {
  dirty.value = false
}
function discard(): void {
  dirty.value = false
}
</script>

<template>
  <SaveBar id="settings-save-bar" v-model:open="dirty" discard-confirmation>
    <button variant="primary" @click="save">Save</button>
    <button @click="discard">Discard</button>
  </SaveBar>
</template>

open, v-model:open, show/hide và việc ẩn khi unmount hoạt động giống như với Modal. discardConfirmation ("whether to show a confirmation dialog when the discard button is clicked") được đặt làm property discardConfirmation của element.

Với một form, attribute data-save-bar trong hướng dẫn embedded app không cần component nào.

Phát hành theo giấy phép MIT. Logo Vue của Evan You, CC BY-NC-SA 4.0.