Laravel 无法在登录的配置文件中查看vue组件
我有一个vue组件,可以在其他用户的配置文件中看到,但在登录用户上看不到 当我访问其他用户的id时,我可以看到该组件,但当我返回到我的id时,它消失了 配置文件url是Laravel 无法在登录的配置文件中查看vue组件,laravel,vue.js,laravel-5.3,vuejs2,vue-component,Laravel,Vue.js,Laravel 5.3,Vuejs2,Vue Component,我有一个vue组件,可以在其他用户的配置文件中看到,但在登录用户上看不到 当我访问其他用户的id时,我可以看到该组件,但当我返回到我的id时,它消失了 配置文件url是/myplace/{username} vue组件: <template> <img src="https://cdn0.iconfinder.com/data/icons/basic-ui-elements-colored/700/09_bell-3-512.png" style="heigh
/myplace/{username}
vue组件:
<template>
<img src="https://cdn0.iconfinder.com/data/icons/basic-ui-elements-colored/700/09_bell-3-512.png" style="height:50px;margin-top: 30px; margin-left:0px!important;">
</template>
<script>
import $ from 'jquery'
import axios from 'axios'
import Notification from './Notification.vue'
export default {
components: { Notification },
props:['username'],
data: () => ({
total: 0,
notifications: []
}),
mounted () {
this.fetch()
if (window.Echo) {
this.listen()
}
this.initDropdown()
},
computed: {
hasUnread () {
return this.total > 0
}
},
methods: {
/**
* Fetch notifications.
*
* @param {Number} limit
*/
fetch (limit = 5) {
axios.get('/notifications', { params: { limit }})
.then(({ data: { total, notifications }}) => {
this.total = total
this.notifications = notifications.map(({ id, data, created }) => {
return {
id: id,
title: data.title,
body: data.body,
created: created,
action_url: data.action_url
}
})
})
},
我认为问题是因为你绑定了用户名。考虑从用户名中删除<代码>:。@ Belmin贝塔克没有工作:(抱歉,但是你发布的代码没有给我们一些有用的信息。这是我从代码中发现的错误。考虑提供更多的代码。@ Belmin BaDAK更新了我的代码。谢谢,当你的组件崩溃时,你在控制台中出错了吗?
<notifications-dropdown :username="{{json_encode($user)}}">
</notifications-dropdown></a>
import './bootstrap'
import Vue from 'vue'
import NotificationsDemo from './components/NotificationsDemo.vue'
import NotificationsDropdown from './components/NotificationsDropdown.vue'
new Vue({
el: '#app',
components: {
NotificationsDemo,
NotificationsDropdown
}
})