简体   繁体   中英

view with vue.js and laravel

Hi i try to make show some data but i make something wrong if i put all stuff on same file for example overview.js den it will be ok. the result should be 3 boxes with some data.

this is my blade.php :

@extends('index')
@section('container')
    <template>
    <div class="row" id="app">
        <div class="col-lg-3 col-sm-6" v-for="stats in statsCards">
            <stats-card>
                <div class="icon-big text-center" :class="`icon-${stats.type}`" slot="header">
                    <i :class="stats.icon"></i>
                </div>
                <div class="numbers" slot="content">
                    <p>{{stats.title}}</p>
                    {{stats.value}}
                </div>
                <div class="stats" slot="footer">
                    <i :class="stats.footerIcon"></i> {{stats.footerText}}
                </div>
            </stats-card>
        </div>
    </div>
        </template>
    <script src="resources/assets/js/app.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>
@endsection 

and this is my vue.js file app.js

import StatsCard from 'js/components/UIComponents/Cards/StatsCard.vue'
new Vue({

    el: '#app',

    export default {
        components: {
            StatsCard

        },

    data() return {

        statsCards: [
            {
                type: 'warning',
                icon: 'ti-server',
                title: 'Capacity',
                value: '105GB',
                footerText: 'Updated now',
                footerIcon: 'ti-reload'
            },
            {
                type: 'success',
                icon: 'ti-wallet',
                title: 'Revenue',
                value: '$1,345',
                footerText: 'Last day',
                footerIcon: 'ti-calendar'
            },
            {
                type: 'danger',
                icon: 'ti-pulse',
                title: 'Errors',
                value: '23',
                footerText: 'In the last hour',
                footerIcon: 'ti-timer'
            },
            {
                type: 'info',
                icon: 'ti-twitter-alt',
                title: 'Followers',
                value: '+45',
                footerText: 'Updated now',
                footerIcon: 'ti-reload'
            }
        ]

    }
}

})

I recieve this error Use of undefined constant stats - assumed 'stats' i don't know what i make wrong any idea ? thanks for your Help.

Blade tries to executes the contents of {{ }} as php. You need to escape it: @{{ }} .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM