vue-component

How to suppress “Undefined” errors before fetching data in Vue

僤鯓⒐⒋嵵緔 提交于 2019-12-02 10:14:50
问题 I have a simple page where I display some data that are fetched from the server. Template: <p>Order's customer name: {{ order.customer.name }}</p> Javascript: export default { data () { return { order: {} } }, mounted () { this.fetchOrder() }, methods: { fetchOrder () { /* get the order data asynchronously from the server */ .success(function () { this.order = data_from_server }) } } } Everything works just fine but in browser's console there is an error: " Cannot read property 'name' of

Why the slider does not work when I click another tab on vue component?

▼魔方 西西 提交于 2019-12-02 10:04:54
My view like this : @foreach($leagues as $league) <a data-toggle="tab" @click="$refs.leagues.changeLeague({{ $league->id }})"> {{ $league->name }} </a> @endforeach ... <div class="tab-pane active"> <top-league class="slick" league-id="{{ $league_id }}" ref="leagues"></top-league> </div> My top league component vue like this : <template> <div class="row"> <div class="col-md-3" v-for="item in items"> <div class="panel panel-default"> <div class="panel-image"> <a :href="baseUrl+'/leagues/'+item.id+'/'+item.name" :style="{backgroundImage: 'url(' + baseUrl + '/img/leagues/'+item.photo+ ')'}"> </a>

How can I use lang class laravel in vue.js 2?

。_饼干妹妹 提交于 2019-12-02 08:48:25
My vue component like this : <template> <ul class="nav nav-tabs nav-tabs-bg"> <li role="presentation" v-for="item in tabs"> 1. failed -> {{ item.name }} 2.success -> {{trans('purchase.payment.tab')}} </li> </ul> </template> <script> export default { data() { return { tabs: [ {name: "trans('purchase.payment.tab')"} ] } } } </script> My lang in laravel(resources/lang/en/purchase.php) like this : <?php return [ 'payment' => [ 'tab' => 'Payment Status', ], ... ]; If the component vue executed, the result like this : failed -> trans('purchase.payment.tab') 2.success -> Payment Status So, if trans

how to share data between components in VUE js (while creating list)

爱⌒轻易说出口 提交于 2019-12-02 08:41:28
Could you please tell me how to share data between components in VUE js (while creating list).I have two components list components and add todo component .I want to add items in list when user click on add button .But issue is input field present in different component and list is present in different component here is my code https://plnkr.co/edit/bjsVWU6lrWdp2a2CjamQ?p=preview // Code goes here var MyComponent = Vue.extend({ template: '#todo-template', props: ['items'] }); var AddTODO = Vue.extend({ template: '#add-todo', props: ['m'], data: function () { return { message: '' } }, methods:

Is the solution for passing data up the chain in Vue.js really to chain event listeners/emitters?

半城伤御伤魂 提交于 2019-12-02 08:35:14
The Vue API Docs/Guide talk about the pattern of parents passing props to children, who communicate back up to their parents via events. Additionally, the guide stresses that children absolutely should not mutate parent data, as that is the responsibility of the parent. For a mostly-flat structure where you have one parent (e.g. 'App') and all components are children of that one parent, this works okay; any event only has to bubble once. However, if you are composing a structure that is compartmentalized (e.g. App (holds state) -> ActiveComponent -> FormGroup -> Inputs...) then building

How to suppress “Undefined” errors before fetching data in Vue

别说谁变了你拦得住时间么 提交于 2019-12-02 07:02:35
I have a simple page where I display some data that are fetched from the server. Template: <p>Order's customer name: {{ order.customer.name }}</p> Javascript: export default { data () { return { order: {} } }, mounted () { this.fetchOrder() }, methods: { fetchOrder () { /* get the order data asynchronously from the server */ .success(function () { this.order = data_from_server }) } } } Everything works just fine but in browser's console there is an error: " Cannot read property 'name' of undefined ". Apparently the problem is that it takes some time to fetch the order data from the server and

Non-scoped styling in components applied only once when switching routes

时光总嘲笑我的痴心妄想 提交于 2019-12-02 06:45:46
问题 Vue.js documentation for Scoped CSS mentions that You can include both scoped and non-scoped styles in the same component I built the example application for vue-router and used two single file components instead of the string templates of the example - the rendering is as expected. I then tried to apply both scoped and non-scoped styles in the components. In the first one I have <style scoped> div { color: white; background-color: blue; } </style> <style> body { background-color: green; } <

Non-scoped styling in components applied only once when switching routes

感情迁移 提交于 2019-12-02 06:34:10
Vue.js documentation for Scoped CSS mentions that You can include both scoped and non-scoped styles in the same component I built the example application for vue-router and used two single file components instead of the string templates of the example - the rendering is as expected. I then tried to apply both scoped and non-scoped styles in the components. In the first one I have <style scoped> div { color: white; background-color: blue; } </style> <style> body { background-color: green; } </style> and the second one <style scoped> div { color: white; background-color: red; } </style> <style>

Import vue package in laravel

*爱你&永不变心* 提交于 2019-12-02 06:17:44
问题 What is the corect way to import vue packages in laravel 5.6? It comes with vue and bootstrap preinstall. I see they are all compile in app.js from public directory but I can figure out how to import https://github.com/moreta/vue-search-select and use it. After I tried to import it on my own: Error: ncaught TypeError: Vue.component is not a function At line: Vue.component('search-user', __webpack_require__(42)); Until now I tried this: assets/js/bootstrap.js: import { BasicSelect } from 'vue

How to use Bootstrap mixins in VueJS components

浪尽此生 提交于 2019-12-02 05:24:57
问题 I'm using vue-cli + bootstrap-vue. I can't figure out why and how bootstrap mixins not working at all despite I imported Bootstrap like this (in my main.js) import 'bootstrap/scss/bootstrap-grid.scss' import 'bootstrap-vue/dist/bootstrap-vue.css' Vue.use(BootstrapVue); And trying to use some mixins inside component <style lang="scss" scoped> .xxx { @include media-breakpoint-up(md) { display: none; } } </style> But if I import missing files everything will be fine: <style lang="scss" scoped>