Vuejs
updated: 2019/1/21 jimp で加工した list 表示でうまく表示タイミングが調整出来なくて加工前や表示自体されなくて躓いた 理由) Due to limitations in JavaScript, Vue cannot detect the following changes to an array: When you directly set an item …
jquery を vue component のどこからでも使えるようにする 参考: stackoverflow.com //
→ @click="method1() & method2()" & でつなげれば出来る ここで()をつけないでメソッド名だけでは動作しない。 &無しの単体のメソッドならば()は不要 別途両方を実行するメソッドを作ってもいいが mixin や vuex で作ったものを2つ利用したいときに無…
vue-router の meta が便利 これで $route.meta.profile に値が付くので v-if="this.$route.meta.profile" 等でブラウザバックにも対応した routing ごとの conditional rendering ができて便利 //
updated: 2018/9/13 Navigation-drawerを子componentで使用したいため、default の data: drawer を親子間で共有したいため、 mixinを使ってcomputed: {drawer: true} で共有した。 すると下記のエラー Computed property “drawer” was assigned to but it h…
updated: 2022/2/18 より良い方法: monteecristoo.hatenablog.com blade template 内の vue component にデータをパスしたい場合 例えば authHome.blade.php / guestHome.blade.php の二つに共通で PageBody.vue という vue component を使うとき、Laravel …
laravel-mix@2.1.11 vue-loader@15.3.0 vue-loader を @14.2.2 から @15.3.0 にアップでしたらエラーが発生 solution: webpack.mix.js にプラグインを適用 let mix = require('laravel-mix'); const VueLoaderPlugin = require('vue-loader/lib/plugin') mix…
responseは[{prop1: {}, prop2: {}}, {prop1: {}, prop2: {}}] とする messages ではこのresponse をすべて格納して modifiedMessages ではprop2を削除して格納したい。 @messages.vue 親コンポーネント <app-messages v-for="message in messages" m=message key=message.id > mounted() { axios.get('getMessages').then(respons</app-messages>…
methods: { testFunc() { console.log('OK'); } }, mounted() { setTimeout(function(){ this.testFunc(); // エラー }, 1000); } this.testFunc() だとエラー。以下に訂正 mounted() { var self = this; setTimeout(function(){ self.testFunc(); // OK },…
computed: { swiper() { return this.$refs.swiper.swiper },} この swiper を孫以降の component で共有したい場合 provide - inject >>> provide は data, method しか共有できない mixin >>> this.$refs が使えない Vuex の state で共有 >>> 〇 親 compo…
大規模開発のため vuex の store.js をモジュール化すると各 component から vuex の action をインポートした際、action がどこのモジュールに含まれているかわからなくなってくる。 @store.js import Vue from 'vue'; import Vuex from 'vuex'; import act…
親子ならprops で可能だが、孫などには provide, injection を使う vuejs.org ただし共有できるのは data, method で computed はできない。 The provide options allows us to specify the data/methods we want to provide to descendent components. では…
updated: 2018/5/2 この記事は検証途中で内容が不正確 方法1 Laravel Mix から @webpack.mix.js let webpack = require('webpack'); mix.webpackConfig({ plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jquery: 'jquery', window.jquery: 'jquery' …
// updated: 2018/4/27 vueJS でスクリーンサイズに応じて処理を切り替えたい場合に関して過去に書いた記事のフォローアップ monteecristoo.hatenablog.com 上記方法だとリロードごとには適用されるが例えばタブレットの縦横を回転させたときなどには適用さ…
// @webpack.mix.js mix.js('resources/assets/js/app.js', 'public/js') .js('resources/assets/js2/app2.js', 'public/js'); @resources/assets/js/app.js app.js に実装したい routing, components を読み込むconst routes = [ { path: '/user/:id', comp…
updated: 2018.11.14 サイドメニュー - メインページ ---- swiper 1 [メインページ内] コンテンツ1 - コンテンツ2 - コンテンツ3 ---- swiper 2 swiper 2 が swiper 1 の中に入れ子になっている場合、swiper2 の swiper-slide-prev が swiper 1 に干渉…
// vue-loader を v13.0.0 以降にアップデートしたら "Failed to mount component: template or render function not defined" vue-loader@13.0.0 以降 ES module が default で true になっているため、古い CommonJS でエラーが発生 solution: // before c…
npm install noty --save @resources/assets/js/bootstrap.js window.noty = require('noty'); @app.blade.php <script> @if(Session::has('success')) new noty({ type: 'success', layout: 'bottomLeft', text: '{{ Session::get('success') }}' }); @endif </script> -----…
computed: { hoge() { return $store.state.hoge } }, Vuex の state は method で hoge.foo などで値を参照できない
#74
Laravel 内の Vue.js vue-loader@13.0.4にアップデートすると [Vue warn]: Failed to mount component: template or render function not defined. とエラーが出るので vue-loader@12.2.2 を使用(要検証) yarn add vue-loader@12.2.2
computed() Computed properties are defined as no-argument functions 参考: stackoverflow.com computed同士なら this.foo で定義した computed 同士で値にアクセスできる computed: { loadedUser() { return this.$store.getters.loadedUser(this.$route…
@someMixin.js export const someMixin = { data() { return { }, methods: { }, computed() { } @someComponent.vue import { someMixin } from './someMixin'; export default { mixins: [someMixin] } #174 global mixin はすべてのsingle vue instance …
bind single class bind object to manage multi css classes <script src="https://unpkg.com/vue"></script><div id="app"> <div class="demo" @click="attachRed = !attachRed" :class="divClasses"> </div> <div class="demo"></div> <dv class="demo"></dv> </div> new Vue({ el: '#app', data: { attachRed: false, }…
state data をとどめておく場所。どの component からも this.$store.state.hoge からアクセス可能 getters state を加工したい場合使用。同じ加工を複数の component で使用したい場合、code の duplicate を防ぐ。どの component からも this.$store.gette…
// updated: 2018/2/21 vue-awesome-swiperはflexboxを使っている。 cssに追加 .swiper-wrapper { display: flex !important; align-item: flex-start; } →→ フレックスボックスの上端をそろえる .swiper-container { overflow: visible !important; } →→ デ…
// updated: 2018/4/25 metismenu ・・・ class metismenuが複数あると2つ目がエラー??? 大画面ではサイドに固定されたmetismenuが使いたい モバイルではスワイプでmetismenuを使ったサイドバーを表示させたい 2種類のサイドバーを用意して画面サイズごと…
blade templateで@section('hoge')を設定したのち、 vue側のapp.jsでvueをinjectするタグを以下のように同じ<hoge>に設定すると… Vue.component('hoge', require('./componets/Hoge.vue')); エラー(コンソールにもコンパイル時もエラーが表示されない)でvueが表示</hoge>…
github.com infinite-loadingの各elementをイベントを通じてcssを管理 ロードされるlist内にcss管理用のvariableを設置する listのelementに無効なクラスを設定しておいて(defaultでは無効でクラス無し扱い)、イベントでクラスを有効化する
Vue-infinite-loadingでv-forのpropertyにエラーが出る場合 <p v-for="(recommend, key) in list"> <div id="recommend"> <span v-text="recommend"></span> </div> </p> <infinite-loading :on-infinite="onInfinite" ref="infiniteLoading"></infinite-loading> 余分な<div>があるとエラーが出る。 解決方法: <p v-for="(recommend, key) in list"> </p></div>