Viblo
  • Posts
  • Questions
  • Discussions
Announcements
No announcement yet.
All Announcements

Nguyen Van Ngoc

@blaysku

Report
  • Posts
  • Series
  • Questions
  • Answers
  • Clips
  • Followings
  • Followers
  • Tags
  • Reputations
  • Communication

[Laravel/VueJS] Hỏi về tổ chức file Laravel/VueJS ?

Nguyen Van Ngoc
Answered May 16th, 2018 8:51 AM

Thế này tạch là đúng rồi. Laravel mặc định nó đã cấu trúc để bác dùng vue trong file blade rồi, bác cứ thế mà làm theo https://github.com/laravel/laravel/blob/master/resources/assets/js/app.js

require('./bootstrap');

window.Vue = require('vue');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

Vue.component('example-component', require('./components/ExampleComponent.vue'));

const app = new Vue({
    el: '#app'
});

Theo đó, thì tất cả các page blade đều phải chứa 1 el #app:

<div id="app">
...
</div>

vẫn code html và php trong file blade bình thường, chổ nào cần xử lý bằng vue thì viết component xử lý cho chổ đó rồi sử dụng (nhớ phải đăng ký component trong app.js): https://github.com/laravel/laravel/blob/master/resources/assets/js/components/ExampleComponent.vue

<div id="app">
<h1>Hello world</h1>

<example-component></example-component>

@foreach ($posts as $post)
    <p>This is post {{ $post->id }}</p>
@endforeach

<ul>
  <li v-for="comment in comments" :key="comment.id" v-text="comment.content"></li>
</ul>

</div>

<script>
var comments = @json($comments);
</script>
+4

Cách bật hay sử dụng chuẩn http2 trên nuxtjs - vuejs?

Nguyen Van Ngoc
Answered May 3rd, 2018 7:00 AM

bạn thử thêm vào nuxt.config.js, xem được ko

http2: {
    push: true
}
0

Tạo tóm tắt cho bài viết trong Laravel 5.

Nguyen Van Ngoc
Answered Apr 25th, 2018 3:32 PM

Lúc submit bài viết thì xử lý strip các tags HTML, loại bỏ nội dung của các tag không cần hiển thị ra description như <img> <code>..., thay thế tag <br> bằng dấu . rồi thực hiện substr để lấy ra đoạn summary rồi lưu vào field summary trong database, lúc này summary chỉ còn thuần string, ko còn các tag html nữa cứ thế lấy ra dùng. Bạn xem thế được ko 😄

+2

Total post views

55.4K

Reputations

1010

Following tags

5

Following users

5

Followers

29

Posts

27

Clips

24

Total questions

0

Total answers

3

Organization


Have no organizations yet.

Posts tendency


Resources

  • Posts
  • Organizations
  • Questions
  • Tags
  • Videos
  • Authors
  • Discussions
  • Recommend System
  • Tools
  • Machine Learning
  • System Status

Services

  • Viblo CV Viblo Code
  • Viblo CV Viblo CV
  • Viblo CTF Viblo CTF
  • Viblo Learning Viblo Learning

Mobile App

Get it on Google Play Download on the App Store
QR code

Links

  • Atom Icon

© 2021 Viblo. All rights reserved.

  • About Us
  • Feedback
  • Help
  • FAQs
  • RSS
  • Terms
  • DMCA.com Protection Status