Skip to content

ベータ

これらの App Bridge コンポーネントは新しく、まだ実際の Shopify 管理画面ではテストされていません。ベータ期間中は、マイナーリリースで API が変わる可能性があります。うまく動かない場合は issue を作成してください。

SaveBar ​

始める前にインストールを、open については Modal を参照してください。

SaveBar は ui-save-bar をレンダリングします。ui-save-bar の型の説明にあるとおり、"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、およびアンマウント時の非表示は、Modal と同様に動作します。 discardConfirmation("whether to show a confirmation dialog when the discard button is clicked")は、要素の discardConfirmation プロパティとして設定されます。

フォームの場合は、埋め込みアプリガイドにある data-save-bar 属性を使えば、コンポーネントは不要です。

MIT ライセンスの下で公開されています。Vue ロゴは Evan You によるもの(CC BY-NC-SA 4.0)。