登录的个人资料

时间:2017-01-21 19:31:02

标签: laravel vue.js laravel-5.3 vuejs2 vue-component

我有一个vue组件,可以在其他用户的个人资料中看到,但不能登录用户。

当我访问其他用户的ID时,我可以看到该组件,但当我回到我的ID时它会消失

个人资料网址为/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
            }
          })
        })
       },
刀片视图中的

<notifications-dropdown :username="{{json_encode($user)}}">
</notifications-dropdown></a>

app.js:

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
  }
})

0 个答案:

没有答案