0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Promiseコード解説(Vue)

Last updated at Posted at 2024-03-20

・<ag-list-footer>など他のファイルはインポートしないで使えるのはなぜ?

import SettingDialog from './SettingDialog.vue';これ書かないとエラーになる

(解)components: {}の中にも定義していたから

  app.jsの中で設定されているのでファイルはインポート書かなくてもタグで使える

<user-save-component ref="SaveDialog" :auth="this.auth" :const="this.const" @onListReload="onGetList"></user-save-component>
        <loading-overlay :loading="loading"></loading-overlay>
        <message-dialog ref="msgDialog"></message-dialog>
  • beforeMountなど、Vueのライフサイクルについて

Promiseには3つの状態がある

処理の順序に

お約束を取り付けることができるもの、

処理を待機することや、その結果に応じて次の処理をすることお約束するもの

だと思っています。

Promiseには、PromiseStatusというstatusがあり、3つのstatusがあります。

  • pending未解決 (処理が終わるのを待っている状態)
  • resolved解決済み (処理が終わり、無事成功した状態)
  • rejected拒否 (処理が失敗に終わってしまった状態)

 getData(sid) {
            // データ取得のPromiseを返す関数
            return new Promise(function(resolve, reject) {
                const axios_class = axios.get(constants.url.endpoint.setting.list + "/" + Number(false));
                const axios_edit_data = axios.get(constants.url.endpoint.setting.data + "/" + sid);
                Promise.all([axios_class, axios_edit_data])
                    .then(response => resolve(response))
                    .catch(error => reject(error));
            });
        },

[axios_class, axios_edit_data]の配列の

追加の時は0番目axios_class→分類で選択肢出すためにlistでデータの一覧を取得する

編集の時はの配列の1番目axios_edit_data→編集する行のsidで1個選んでその行のデータを取ってくる

<!-- 分類 -->
                        <v-col class="pt-0" cols="12" xs="12" sm="12" md="12" lg="12" xl="12">
                            <v-autocomplete
                                :items="classList"
                                item-value="class_cd"
                                item-text="class_name"
                                v-model="classValue"
                                label="分類*"
                                **return-object**
                                :rules="isNewClass ? [] : [inputRules.requiredSel]"
                                :disabled="isEditMode"
                            >
                            <template v-slot:append-outer v-if="!isEditMode">
                                    <v-icon @click="isNewClass = !isNewClass">mdi-plus</v-icon>
                                </template>
                            </v-autocomplete>
                        </v-col>

:disabled="isEditMode" 触れなくする

return-object

が書いてあるときはデータ1個(nameとか)じゃなくて、全部(1件丸ごと)渡す。

使うのは何を基準に決める?

:rules="isNewClass ? [] : [inputRules.requiredSel]"

ルールの条件 **isNewClasstrueの場合、:rulesには空の配列[]**が指定されます


        <!-- 一覧 -->
        <div>
            <ag-grid-vue class="ag-theme-alpine" style="height: calc(100vh - 200px);min-height: 340px;"
                :gridOptions="gridOptions"
                :rowData="rowData"
                :modules="modules"
                :context="context"
                :frameworkComponents="frameworkComponents"
            />
        </div>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?