主頁 > 移動端開發 > 在VUE中從模態視圖獲取值到主視圖

在VUE中從模態視圖獲取值到主視圖

2022-02-18 16:29:07 移動端開發

我在 Vue 中制作了我的第一個專案。

我有一個小問題。我需要從 Datatable 中獲取一個值(在代碼中標記:console.log (self.selectedContent); // 這是我的結果@@) - 到我的主視圖并顯示它。我怎樣才能做到這一點?

我的 Main.vue:

<template>
  <CCard>
    <CCardHeader>
      <CIcon name="cil-input-power"/>
      Dodaj zlecenie
    </CCardHeader>
    <CCardBody>
      <CRow>
        <CCol sm="12">
          <CForm>
            <div class="tab-content py-3" id="myTabContent">
              <div class="tab-pane fade" :class="{ 'active show': isActive('tab1') }" id="tab1">
                <h4 class="py-3 d-inline-block pe-5 me-5">Dane przewo?nika </h4>

                <CButton
                  @click="warningModal = true"
                  color="primary"
                >
                  Uzupe?nij
                </CButton>
                <CInput
                  v-model.trim="$v.form.carrier_id.$model"
                  :isValid="checkIfValid('carrier_id')"
                  type="hidden"
                />
                <CRow>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="Nazwa przewo?nika*"
                      v-model.trim="$v.form.carrier_name.$model"
                      :isValid="checkIfValid('carrier_name')"
                      placeholder="Wpisz nazw? przewo?nika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="NIP przewo?nika*"
                      v-model.trim="$v.form.carrier_nip.$model"
                      :isValid="checkIfValid('carrier_nip')"
                      placeholder="Wpisz NIP przewo?nika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                </CRow>
                <CRow>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="Regon przewo?nika*"
                      v-model.trim="$v.form.carrier_regon.$model"
                      :isValid="checkIfValid('carrier_regon')"
                      placeholder="Wpisz regon przewo?nika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="Email przewo?nika*"
                      v-model.trim="$v.form.carrier_email.$model"
                      :isValid="checkIfValid('carrier_email')"
                      placeholder="Wpisz email przewo?nika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                </CRow>
                <CRow>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="Telefon przewo?nika*"
                      v-model.trim="$v.form.carrier_phone.$model"
                      :isValid="checkIfValid('carrier_phone')"
                      placeholder="Wpisz telefon przewo?nika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="Kod pocztowy przewodnika*"
                      v-model.trim="$v.form.carrier_postal_code.$model"
                      :isValid="checkIfValid('carrier_postal_code')"
                      placeholder="Wpisz kod pocztowy przewodnika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                </CRow>
                <CRow>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="Adres przewo?nika*"
                      v-model.trim="$v.form.carrier_street.$model"
                      :isValid="checkIfValid('carrier_street')"
                      placeholder="Wpisz adres przewo?nika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                  <CCol md="6">
                    <CInput
                      maxlength="255"
                      label="Miasto przewodnika*"
                      v-model.trim="$v.form.carrier_city.$model"
                      :isValid="checkIfValid('carrier_city')"
                      placeholder="Wpisz miasto przewodnika"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                </CRow>
                <CRow>
                  <CCol md="12">
                    <CInput
                      maxlength="255"
                      label="Email do powiadomień*"
                      v-model.trim="$v.form.carrier_email_to_notification.$model"
                      :isValid="checkIfValid('carrier_email_to_notification')"
                      placeholder="Wpisz email do powiadomień"
                      invalidFeedback="To pole jest wymagane i musi zawiera? minimum 3 znaki i maksimum 255 znaków"
                    />
                  </CCol>
                </CRow>
                <h4 class="py-3">Kierowca </h4>
                <CRow>
                  <CCol md="12">
                    <CSelect id="driver_id"
                             label="Wybierz kierowc?"
                             v-model.trim="$v.form.driver_id.$model"
                             :options="drivers"
                    >
                    </CSelect>
                  </CCol>
                </CRow>
                

                <h4 class="py-3">Rodzaj przewo?onego towaru </h4>
              
                <template v-for="(option) in productDircionary">
                  <div class="form-group form-row" :key="option.name">
                    <CCol sm="12">
                      <input type="checkbox" name="selectedProducts[]" :value="option.value" v-model="selectedProducts"
                             :id="option.value" :checked="selectedProducts.includes(option.value)"/> {{ option.label }}
                    </CCol>
                  </div>
                </template>


                <div>wybrano: {{ selectedProducts }}</div>

                <h4 class="py-3">Wymagane dokumenty </h4>
               

                <template v-for="(option) in documentDircionary">
                  <div class="form-group form-row" :key="option.name">
                    <CCol sm="12">
                      <input type="checkbox" name="selectedDocuments[]" :value="option.value"
                             v-model="selectedDocuments" :id="option.value"
                             :checked="selectedDocuments.includes(option.value)"/> {{ option.label }}
                    </CCol>
                  </div>
                </template>
                <div>wybrano: {{ selectedDocuments }}</div>


                <h4 class="py-3">Wymagane pliki dla dostawcy </h4>
                <template v-for="(option) in fileDircionary">
                  <div class="form-group form-row" :key="option.name">
                    <CCol sm="12">
                      <input type="checkbox" name="selectedFiles[]" :value="option.value" v-model="selectedFiles"
                             :id="option.value" :checked="selectedFiles.includes(option.value)"/> {{ option.label }}
                    </CCol>
                  </div>
                </template>
                <div>wybrano: {{ selectedFiles }}</div>

                <CButton
                  color="primary"
                  @click="submit"
                >
                  Zapisz
                </CButton>
                <CButton
                  class="ml-1"
                  color="success"
                  @click="goBack"
                >
                  Cofnij
                </CButton>
              </div>
              <div class="tab-pane fade" :class="{ 'active show': isActive('tab2') }" id="tab2">Historia zmian</div>
              <div class="tab-pane fade" :class="{ 'active show': isActive('tab3') }" id="tab3">Pliki</div>
              <div class="tab-pane fade" :class="{ 'active show': isActive('tab4') }" id="tab4">
                <CRow>
                  <CCol md="12">
                    <CTextarea
                      label="Uwagi do dostawy"
                      placeholder="Uwagi do dostawy"
                      rows="9"
                      v-model.trim="$v.form.deliver_comments.$model"
                    />
                  </CCol>
                </CRow>
                <CRow>
                  <CCol md="12">
                    Podpis odbiorcy delivery_signature
                  </CCol>
                </CRow>
                <CButton
                  color="primary"
                  @click="submit"
                >
                  Zapisz
                </CButton>
                <CButton
                  class="ml-1"
                  color="success"
                  @click="goBack"
                >
                  Cofnij
                </CButton>
              </div>
            </div>
          </CForm>
          <br/>
          <div>
            <CModal
              title="Wybierz przewo?nika"
              color="info"
              :show.sync="warningModal"
              size="xl"
              :closeOnBackdrop=true
              @closed="closedEvent"
              :centered="true"
              :onclose="closedEvent"
            >
              <data-table-select
                :fetch-url="datatTableUrl"
                :columns="['id', 'email', 'name', 'surname']"
                :headers="{'id': 'ID','email': 'Email','name': 'Imi?','surname': 'Nazwisko'}"
                :routeName="routeName"
              ></data-table-select>
            </CModal>
          </div>
        </CCol>
      </CRow>
    </CCardBody>
  </CCard>
</template>

<script>
import axios from 'axios';
import Vue from 'vue';
import CKEditor from 'ckeditor4-vue';
import Swal from "sweetalert2";
import {validationMixin} from "vuelidate"
import {required, minLength, email, sameAs, helpers} from "vuelidate/lib/validators"
import Datepicker from 'vuejs-datepicker';
import {pl} from 'vuejs-datepicker/dist/locale'
import DataTableSelect from "../../components/DataTableSelect";

export default {
  components: {
    DataTableSelect,
    Datepicker
  },
  data() {
    return {
      warningModal: false,
      datatTableUrl: '',
      routeName: 'carriers',
      modalClasses: ['modal', 'fade'],
      checkedNames: [],
      pl: pl,
      activeItem: 'home',
      form: {
        carrier_id: null,
        carrier_name: null,
        carrier_nip: null,
        carrier_regon: null,
        carrier_email: null,
        carrier_postal_code: null,
        carrier_street: null,
        carrier_city: null,
        carrier_email_to_notification: null,
        driver_id: null,
        comments: null,
        transport_content: null,
        deliver_comments: null,
        carrier_phone: null,
      },
      confirmationTypes: [],
      transportTypes: [],
      drivers: [],
      productDircionary: [],
      documentDircionary: [],
      fileDircionary: [],
      selectedProducts: [],
      selectedDocuments: [],
      selectedFiles: [],
    }
  },
  computed: {
    formString() {
      return JSON.stringify(this.form, null, 4)
    },
    isValid() {
      return !this.$v.form.$invalid
    },
    isDirty() {
      return this.$v.form.$anyDirty
    },
  },
  mixins: [validationMixin],
  validations: {
    form: {
      speed_number: {
        required,
        minLength: minLength(3),
        maxLength: 255
      },
      ...
    }
  },
  methods: {
    closedEvent(){
      alert();
    },
    isActive(menuItem) {
      return this.activeItem === menuItem
    },
    setActive(menuItem) {
      this.activeItem = menuItem
    },
    goBack() {
      this.$router.replace({path: '/tasks'})
    },
    checkIfValid(fieldName) {
      const field = this.$v.form[fieldName]
      if (!field.$dirty) {
        return null
      }
      return !(field.$invalid || field.$model === '')
    },
    store() {
      let self = this;

      axios.post(this.$apiAdress   '/api/tasks?token='   localStorage.getItem("api_token"),
        {
          carrier_id: self.form.carrier_id,
          carrier_name: self.form.carrier_name,
          carrier_nip: self.form.carrier_nip,
          carrier_regon: self.form.carrier_regon,
          carrier_email: self.form.carrier_email,
          carrier_postal_code: self.form.carrier_postal_code,
          carrier_street: self.form.carrier_street,
          carrier_city: self.form.carrier_city,
          carrier_email_to_notification: self.form.carrier_email_to_notification,
          driver_id: self.form.driver_id,
          comments: self.form.comments,
          transport_content: self.form.transport_content,
          deliver_comments: self.form.deliver_comments,
          carrier_phone: self.form.carrier_phone,
          selected_products: self.selectedProducts,
          selected_documents: self.selectedDocuments,
          selected_files: self.selectedFiles,
        })
        .then(function (response) {
          if (response.data.status == 'success') {
            Swal.fire(
              'Sukces',
              'Rekord dodany poprawnie!',
              'success'
            ).then(function () {
              // self.$router.push('/tasks');
            });
          } else {
            Swal.fire(
              'B??d',
              response,
              'error'
            )
          }
        }).catch(function (error) {
        if (error.response.data.message != '') {
          let errorDetails = ""
          for (let key in error.response.data.errors) {
            errorDetails  = `${error.response.data.errors[key]}<br/>`
          }
          Swal.fire(
            'B??d',
            errorDetails,
            'error'
          )
          window.scrollTo({top: 0});
        } else {
          Swal.fire(
            'B??d',
            error,
            'error'
          )
          self.$router.push({path: 'login'});
        }
      });
    },

    submit() {
      let self = this;

      Swal.fire({
        title: "Czy zapisa? dane",
        text: "zlecenia w bazie?",
        type: "question",
        showCancelButton: true,
        confirmButtonText: "Tak, zapisz",
        cancelButtonText: "Anuluj",
        reverseButtons: true
      }).then(function (result) {
        if (result.value) {
          self.runSubmit();
        }
      });
    },

    runSubmit() {
      let self = this;
      self.validate();
      if (!this.$v.form.$invalid) {
        this.store();
      }
    },

    validate() {
      this.$v.$touch()
    },

    reset() {
      this.form = this.getEmptyForm()
      this.submitted = false
      this.$v.$reset()
    },

    getEmptyForm() {
      return {
        speed_number: null,
        order_number: null,
        data_start: null,
        data_finish: null,
        address_from: null,
        address_to: null,
        is_neutral_option: null,
        transport_type: null,
        carrier_id: null,
        carrier_name: null,
        carrier_nip: null,
        carrier_regon: null,
        carrier_email: null,
        carrier_postal_code: null,
        carrier_street: null,
        carrier_city: null,
        carrier_email_to_notification: null,
        driver_id: null,
        comments: null,
        transport_content: null,
        deliver_comments: null,
        carrier_phone: null,
        selected_products: null,
        selectedProducts: [],
        selectedDocuments: [],
        selectedFiles: [],
      }
    }
  },
  created: function () {
    this.datatTableUrl = Vue.prototype.$apiAdress   '/api/tasks/carriers-table?token='   localStorage.getItem("api_token");
    let self = this;
    self.setActive('tab1');
    axios.get(this.$apiAdress   '/api/tasks/create?token='   localStorage.getItem("api_token"))
      .then(function (response) {
        self.confirmationTypes = response.data.confirmationTypes;
        self.drivers = response.data.drivers;
        self.transportTypes = response.data.transportTypes;
        self.productDircionary = response.data.productDircionary;
        self.documentDircionary = response.data.documentDircionary;
        self.fileDircionary = response.data.fileDircionary;
      }).catch(function (error) {
      console.log(error);
      self.$router.push({path: '/login'});
    });
  }
}
</script>

和資料表:

<template>
  <div>
    <div class="row mb-3">
      <div class="col-3">
        <div class="input-group">
          <input
            v-model="search"
            class="form-control"
            placeholder="Szukaj..."
            type="text"
            @keyup.enter="handleSearch"
          >
          <div class="input-group-append">
            <button class="btn btn-primary" type="button" @click.prevent="handleSearch">
              <font-awesome-icon icon="fas fa-search"/>
            </button>
          </div>
        </div>
      </div>

      <div class="col-2">
        <div class="input-group">
          <label for="pageOption" class="mt-2 mr-2">Na stronie</label>
          <select class="form-control" v-model="perPage" @change="handlePerPage" id="pageOption">
            <option v-for="page in pageOptions" :key="page" :value="page">{{ page }}</option>
          </select>
        </div>
      </div>
    </div>


    <table class="table table-hover">
      <thead>
      <tr>
        <th class="table-head">#</th>
       
        <th v-for="(label, column) in headers" :key="column" @click="sortByColumn(column)" class="table-head">
          {{ label | columnHead }}
          <span v-if="column === sortedColumn">
                            <font-awesome-icon v-if="order === 'asc'"  icon="fas fa-angle-up" />
                            <font-awesome-icon v-else icon="fas fa-angle-down" />
            </span>
        </th>
        <th class="table-head">Opcje</th>
      </tr>
      </thead>
      <tbody>
      <tr class="" v-if="tableData.length === 0">
        <td class="lead text-center" :colspan="columns.length   1">Brak danych do wy?wietlenia.</td>
      </tr>
      <tr v-for="(data, key1) in tableData" :key="data.id" class="m-datatable__row" v-else>
        <td>{{ serialNumber(key1) }}</td>
        <td v-for="(value, key) in data" style="cursor: pointer">{{ value }}</td>
        <td><button class="btn btn-primary" @click="prepareAddToTask(data.id)">Wybierz</button></td>
      </tr>
      </tbody>
    </table>
    <nav v-if="pagination && tableData.length > 0">
      <ul class="pagination">
        <li class="page-item" :class="{'disabled' : currentPage === 1}">
          <a class="page-link" href="#" @click.prevent="changePage(currentPage - 1)">Poprzednia</a>
        </li>
        <li v-for="page in pagesNumber" class="page-item"
            :class="{'active': page == pagination.meta.current_page}">
          <a href="javascript:void(0)" @click.prevent="changePage(page)" class="page-link">{{ page }}</a>
        </li>
        <li class="page-item" :class="{'disabled': currentPage === pagination.meta.last_page }">
          <a class="page-link" href="#" @click.prevent="changePage(currentPage   1)">Nast?pna</a>
        </li>
        <span style="margin-top: 8px;"> &nbsp; <i>Wy?wietlam {{ pagination.data.length }} z {{ pagination.meta.total }} wyników.</i></span>
      </ul>
    </nav>

  </div>
</template>

<script type="text/ecmascript-6">
import axios from 'axios';
import Vue from 'vue';
import 'vuejs-datatable/dist/themes/bootstrap-4.esm';
import {
  VuejsDatatableFactory,
  IDataFnParams,
  IDisplayHandlerParam,
  ITableContentParam,
  TColumnsDefinition,
  VueDatatable
} from 'vuejs-datatable';

Vue.use(VuejsDatatableFactory, VueDatatable);
import Swal from 'sweetalert2';

export default {
  props: {
    fetchUrl: {type: String, required: true},
    columns: {type: Array, required: true},
    headers: {type: Object, required: true},
    routeName: {type: String, required: true},
    showUrl: {type: String, required: false},
  },
  data() {
    return {
      tableData: [],
      url: '',
      pagination: {
        meta: {to: 1, from: 1}
      },
      offset: 4,
      currentPage: 1,
      perPage: 100,
      sortedColumn: this.columns[0],
      order: 'asc',
      search: '',
      pageOptions: [100, 200, 500, 1000],
      selectedContent: ''
    }
  },
  watch: {
    fetchUrl: {
      handler: function (fetchUrl) {
        this.url = fetchUrl
      },
      immediate: true
    }
  },
  created() {
    console.log(this.fetchUrl);
    return this.fetchData()
  },
  computed: {
    /**
     * Get the pages number array for displaying in the pagination.
     * */
    pagesNumber() {
      if (!this.pagination.meta.to) {
        return []
      }
      let from = this.pagination.meta.current_page - this.offset
      if (from < 1) {
        from = 1
      }
      let to = from   (this.offset * 2)
      if (to >= this.pagination.meta.last_page) {
        to = this.pagination.meta.last_page
      }
      let pagesArray = []
      for (let page = from; page <= to; page  ) {
        pagesArray.push(page)
      }
      return pagesArray
    },
    /**
     * Get the total data displayed in the current page.
     * */
    totalData() {
      return (this.pagination.meta.to - this.pagination.meta.from)   1
    }
  },
  methods: {
    fetchData() {
      let dataFetchUrl = `${this.url}&page=${this.currentPage}&column=${this.sortedColumn}&order=${this.order}&per_page=${this.perPage}&search=${this.search}`
      axios.get(dataFetchUrl)
        .then(({data}) => {
          this.pagination = data
          this.tableData = data.data
        }).catch(error => this.tableData = [])
    },
    /**
     * Get the serial number.
     * @param key
     * */
    serialNumber(key) {
      return (this.currentPage - 1) * this.perPage   1   key
    },
    /**
     * Change the page.
     * @param pageNumber
     */
    changePage(pageNumber) {
      this.currentPage = pageNumber
      this.fetchData()
    },
    /**
     * Sort the data by column.
     * */
    sortByColumn(column) {
      if (column === this.sortedColumn) {
        this.order = (this.order === 'asc') ? 'desc' : 'asc'
      } else {
        this.sortedColumn = column
        this.order = 'asc'
      }
      this.fetchData()
    },
    handleSearch() {
      this.fetchData()
    },
    handlePerPage($event) {
      this.perPage = $event.target.value;
      this.fetchData()
    },

    recordLink(id) {
      return this.routeName   `/${id.toString()}`
    },
    showRecord(id) {
      const recordLink = this.recordLink(id);
      this.$router.push({path: recordLink});
    },
    getDataRecord(id) {
      let self = this;
      axios.get(this.$apiAdress   '/api/carriers/'   id   '/edit?token='   localStorage.getItem("api_token"))
        .then(function (response) {
          self.selectedContent = response.data.record;
          console.log(self.selectedContent); // here is my result @@

        }).catch(function (error) {
        console.log(error);
        self.$router.push({path: '/login'});
      });
    },
    prepareAddToTask(id){
      const copyId = id;
      Swal.fire({
        title: 'Czy na pewno',
        text: "Chcesz doda? tego przewo?nika?",
        type: 'question',
        showCancelButton: true,
        confirmButtonColor: '#d33',
        cancelButtonColor: '#3085d6',
        confirmButtonText: 'Tak!',
        cancelButtonText: 'Anuluj',
        buttonsStyling: true
      }).then((isConfirm) => {
        // now 'this' depends on the lexical enviroment.
        if(isConfirm.value === true) {
          this.getDataRecord(copyId);
        }
      });
    }
    ///
  },
  filters: {
    columnHead(value) {
      return value.split('_').join(' ').toUpperCase()
    }
  },
  name: 'DataTable'
}
</script>

我需要在控制臺日志中顯示從模態/資料表獲得的 Main.VUE 內容。

我怎樣才能做到?

uj5u.com熱心網友回復:

由于您是 Vue.js 的新手,我建議您閱讀有關props-down and events-up patternVue 組件之間資料流的描述。

  1. props-down 部分描述了資料流 PARENT -> CHILD,這意味著子組件應該通過props從父組件接收資料。
  2. Events-up 部分描述的是資料流 CHILD -> PARENT,這意味著子組件應該通過發出事件來向父組件發送資料。

要回到您的具體情況,您需要從Datatable.vue您將處理的組件中發出一個事件Main.vue

在你的Datatable.vue你應該添加這個:

 getDataRecord(id) {
      let self = this;
      axios.get(this.$apiAdress   '/api/carriers/'   id   '/edit?token='   localStorage.getItem("api_token"))
        .then(function (response) {
          self.selectedContent = response.data.record;
          self.$emit('content-selected', self.selectedContent);  <-- add this line
        }).catch(function (error) {
        console.log(error);
        self.$router.push({path: '/login'});
      });
  },

現在,Main.vue您需要像這樣處理事件:

<data-table-select
      :fetch-url="datatTableUrl"
      :columns="['id', 'email', 'name', 'surname']"
      :headers="{'id': 'ID','email': 'Email','name': 'Imi?','surname': 'Nazwisko'}"
      :routeName="routeName"
      @content-selected="handleContentSelected($event)"  <-- add this line
></data-table-select>

現在,添加將處理事件的函式,在您的方法中添加:

handleContentSelected(content) {
     console.log(content); <-- your data should be here
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/426725.html

標籤:javascript Vue.js

上一篇:Vuetify-卡片上的行居中復選框

下一篇:Vue3:如何在方法函式中訪問狀態

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【從零開始擼一個App】Dagger2

    Dagger2是一個IOC框架,一般用于Android平臺,第一次接觸的朋友,一定會被搞得暈頭轉向。它延續了Java平臺Spring框架代碼碎片化,注解滿天飛的傳統。嘗試將各處代碼片段串聯起來,理清思緒,真不是件容易的事。更不用說還有各版本細微的差別。 與Spring不同的是,Spring是通過反射 ......

    uj5u.com 2020-09-10 06:57:59 more
  • Flutter Weekly Issue 66

    新聞 Flutter 季度調研結果分享 教程 Flutter+FaaS一體化任務編排的思考與設計 詳解Dart中如何通過注解生成代碼 GitHub 用對了嗎?Flutter 團隊分享如何管理大型開源專案 插件 flutter-bubble-tab-indicator A Flutter librar ......

    uj5u.com 2020-09-10 06:58:52 more
  • Proguard 常用規則

    介紹 Proguard 入口,如何查看輸出,如何使用 keep 設定入口以及使用實體,如何配置壓縮,混淆,校驗等規則。

    ......

    uj5u.com 2020-09-10 06:59:00 more
  • Android 開發技術周報 Issue#292

    新聞 Android即將獲得類AirDrop功能:可向附近設備快速分享檔案 谷歌為安卓檔案管理應用引入可安全隱藏資料的Safe Folder功能 Android TV新主界面將顯示電影、電視節目和應用推薦內容 泄露的Android檔案暗示了傳說中的谷歌Pixel 5a與折疊屏新機 谷歌發布Andro ......

    uj5u.com 2020-09-10 07:00:37 more
  • AutoFitTextureView Error inflating class

    報錯: Binary XML file line #0: Binary XML file line #0: Error inflating class xxx.AutoFitTextureView 解決: <com.example.testy2.AutoFitTextureView android: ......

    uj5u.com 2020-09-10 07:00:41 more
  • 根據Uri,Cursor沒有獲取到對應的屬性

    Android: 背景:呼叫攝像頭,拍攝視頻,指定保存的地址,但是回傳的Cursor檔案,只有名稱和大小的屬性,沒有其他諸如時長,連ID屬性都沒有 使用 cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATIO ......

    uj5u.com 2020-09-10 07:00:44 more
  • Android連載29-持久化技術

    一、持久化技術 我們平時所使用的APP產生的資料,在記憶體中都是瞬時的,會隨著斷電、關機等丟失資料,因此android系統采用了持久化技術,用于存盤這些“瞬時”資料 持久化技術包括:檔案存盤、SharedPreference存盤以及資料庫存盤,還有更復雜的SD卡記憶體儲。 二、檔案存盤 最基本存盤方式, ......

    uj5u.com 2020-09-10 07:00:47 more
  • Android Camera2Video整合到自己專案里

    背景: Android專案里呼叫攝像頭拍攝視頻,原本使用的 MediaStore.ACTION_VIDEO_CAPTURE, 后來因專案需要,改成了camera2 1.Camera2Video 官方demo有點問題,下載后,不能直接整合到專案 問題1.多次拍攝視頻崩潰 問題2.雙擊record按鈕, ......

    uj5u.com 2020-09-10 07:00:50 more
  • Android 開發技術周報 Issue#293

    新聞 谷歌為Android TV開發者提供多種新功能 Android 11將自動填表功能整合到鍵盤輸入建議中 谷歌宣布Android Auto即將支持更多的導航和數字停車應用 谷歌Pixel 5只有XL版本 搭載驍龍765G且將比Pixel 4更便宜 [圖]Wear OS將迎來重磅更新:應用啟動時間 ......

    uj5u.com 2020-09-10 07:01:38 more
  • 海豚星空掃碼投屏 Android 接收端 SDK 集成 六步驟

    掃碼投屏,開放網路,獨占設備,不需要額外下載軟體,微信掃碼,發現設備。支持標準DLNA協議,支持倍速播放。視頻,音頻,圖片投屏。好點意思。還支持自定義基于 DLNA 擴展的操作動作。好像要收費,沒體驗。 這里簡單記錄一下集成程序。 一 跟目錄的build.gradle添加私有mevan倉庫 mave ......

    uj5u.com 2020-09-10 07:01:43 more
最新发布
  • 歡迎頁輪播影片

    如圖,引導開始,球從上落下,同時淡入文字,然后文字開始輪播,最后一頁時停止,點擊進入首頁。 在來看看效果圖。 重力球先不講,主要歡迎輪播簡單實作 首先新建一個類 TextTranslationXGuideView,用于影片展示 文本是類似的,最后會有個圖片箭頭影片,布局很簡單,就是一個 TextVi ......

    uj5u.com 2023-04-20 08:40:31 more
  • 【FAQ】關于華為推送服務因營銷訊息頻次管控導致服務通訊類訊息

    一. 問題描述 使用華為推送服務下發IM訊息時,下發訊息請求成功且code碼為80000000,但是手機總是收不到訊息; 在華為推送自助分析(Beta)平臺查看發現,訊息發送觸發了頻控。 二. 問題原因及背景 2023年1月05日起,華為推送服務對咨詢營銷類訊息做了單個設備每日推送數量上限管理,具體 ......

    uj5u.com 2023-04-20 08:40:11 more
  • 歡迎頁輪播影片

    如圖,引導開始,球從上落下,同時淡入文字,然后文字開始輪播,最后一頁時停止,點擊進入首頁。 在來看看效果圖。 重力球先不講,主要歡迎輪播簡單實作 首先新建一個類 TextTranslationXGuideView,用于影片展示 文本是類似的,最后會有個圖片箭頭影片,布局很簡單,就是一個 TextVi ......

    uj5u.com 2023-04-20 08:39:36 more
  • 【FAQ】關于華為推送服務因營銷訊息頻次管控導致服務通訊類訊息

    一. 問題描述 使用華為推送服務下發IM訊息時,下發訊息請求成功且code碼為80000000,但是手機總是收不到訊息; 在華為推送自助分析(Beta)平臺查看發現,訊息發送觸發了頻控。 二. 問題原因及背景 2023年1月05日起,華為推送服務對咨詢營銷類訊息做了單個設備每日推送數量上限管理,具體 ......

    uj5u.com 2023-04-20 08:39:13 more
  • iOS從UI記憶體地址到讀取成員變數(oc/swift)

    開發除錯時,我們發現bug時常首先是從UI顯示發現例外,下一步才會去定位UI相關連的資料的。XCode有給我們提供一系列debug工具,但是很多人可能還沒有形成一套穩定的除錯流程,因此本文嘗試解決這個問題,順便提出一個暴論:UI顯示例外問題只需要兩個步驟就能完成定位作業的80%: 定位例外 UI 組 ......

    uj5u.com 2023-04-19 09:16:23 more
  • FIDE重磅更新!性能飛躍!體驗有禮!

    FIDE 開發者工具重構升級啦!實作500%性能提升,誠邀體驗! 一直以來不少開發者朋友在社區反饋,在使用 FIDE 工具的程序中,時常會遇到諸如加載不及時、代碼預覽/渲染性能不如意的情況,十分影響開發體驗。 作為技術團隊,我們深知一件趁手的開發工具對開發者的重要性,因此,在2023年開年,FinC ......

    uj5u.com 2023-04-19 09:16:15 more
  • 游戲內嵌社區服務開放,助力開發者提升玩家互動與留存

    華為 HMS Core 游戲內嵌社區服務提供快速訪問華為游戲中心論壇能力,支持玩家直接在游戲內瀏覽帖子和交流互動,助力開發者擴展內容生產和觸達的場景。 一、為什么要游戲內嵌社區? 二、游戲內嵌社區的典型使用場景 1、游戲內打開論壇 您可以在游戲內繪制論壇入口,為玩家提供沉浸式發帖、瀏覽、點贊、回帖、 ......

    uj5u.com 2023-04-19 09:15:46 more
  • iOS從UI記憶體地址到讀取成員變數(oc/swift)

    開發除錯時,我們發現bug時常首先是從UI顯示發現例外,下一步才會去定位UI相關連的資料的。XCode有給我們提供一系列debug工具,但是很多人可能還沒有形成一套穩定的除錯流程,因此本文嘗試解決這個問題,順便提出一個暴論:UI顯示例外問題只需要兩個步驟就能完成定位作業的80%: 定位例外 UI 組 ......

    uj5u.com 2023-04-19 09:14:53 more
  • FIDE重磅更新!性能飛躍!體驗有禮!

    FIDE 開發者工具重構升級啦!實作500%性能提升,誠邀體驗! 一直以來不少開發者朋友在社區反饋,在使用 FIDE 工具的程序中,時常會遇到諸如加載不及時、代碼預覽/渲染性能不如意的情況,十分影響開發體驗。 作為技術團隊,我們深知一件趁手的開發工具對開發者的重要性,因此,在2023年開年,FinC ......

    uj5u.com 2023-04-19 09:14:08 more
  • 游戲內嵌社區服務開放,助力開發者提升玩家互動與留存

    華為 HMS Core 游戲內嵌社區服務提供快速訪問華為游戲中心論壇能力,支持玩家直接在游戲內瀏覽帖子和交流互動,助力開發者擴展內容生產和觸達的場景。 一、為什么要游戲內嵌社區? 二、游戲內嵌社區的典型使用場景 1、游戲內打開論壇 您可以在游戲內繪制論壇入口,為玩家提供沉浸式發帖、瀏覽、點贊、回帖、 ......

    uj5u.com 2023-04-19 09:08:34 more