天山网艾克

4813 经验值

Example.vue 文件没改过,Laravel 5.3, vuejs

 "vue": "^1.0.26",
    "vue-resource": "^0.9.3"
/**
 * First we will load all of this project's JavaScript dependencies which
 * include Vue and Vue Resource. This gives a great starting point for
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the body of the page. From here, you may begin adding components to
 * the application, or feel free to tweak this setup for your needs.
 */

Vue.component('example', require('./components/Example.vue'));
Vue.component('question-follow-button', require('./components/QuestionFollowButton.vue'));

const app = new Vue({
    el: 'body'
});
window._ = require('lodash');

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

window.$ = window.jQuery = require('jquery');
require('bootstrap-sass');
require('./select2.min');

/**
 * Vue is a modern JavaScript library for building interactive web interfaces
 * using reactive data binding and reusable components. Vue's API is clean
 * and simple, leaving you to focus on building your next great project.
 */

window.Vue = require('vue');
require('vue-resource');

/**
 * We'll register a HTTP interceptor to attach the "CSRF" header to each of
 * the outgoing requests issued by this application. The CSRF middleware
 * included with Laravel will automatically verify the header's value.
 */

Vue.http.interceptors.push((request, next) => {
    request.headers['X-CSRF-TOKEN'] = Laravel.csrfToken;
    next();
});

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from "laravel-echo"

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });
Example.vue?dd4e:5[vue-loader] resources/assets/js/components/Example.vue: named exports in *.vue files are ignored.(anonymous function) @ Example.vue?dd4e:5(anonymous function) @ app.js:301__webpack_require__ @ app.js:20(anonymous function) @ app.js?8b67:17(anonymous function) @ app.js:588__webpack_require__ @ app.js:20(anonymous function) @ app.js:64(anonymous function) @ app.js:67
QuestionFollowButton.vue?4972:5[vue-loader] resources/assets/js/components/QuestionFollowButton.vue: named exports in *.vue files are ignored.(anonymous function) @ QuestionFollowButton.vue?4972:5(anonymous function) @ app.js:307__webpack_require__ @ app.js:20(anonymous function) @ app.js?8b67:18(anonymous function) @ app.js:588__webpack_require__ @ app.js:20(anonymous function) @ app.js:64(anonymous function) @ app.js:67
vue.common.js?e881:10233 Download the Vue Devtools for a better development experience:
https://github.com/vuejs/vue-devtools

我在console.log(response.data); 的时候 没有出现任何内容, 出现两个warning, 好像API也没有调用似的, show页面里 显示的正常,gulp 也正常 不知道什么问题

<script>
    export default {
        props:['question','user'],
        mounted() {
            this.$http.post('/api/question/follower',{'question':this.question,'user':this.user}).then( response => {
                console.log(response.data);
            });
        },
        data() {
           return {
               followed :false,
           }
        },
        computed: {
            text() {
                return this.followed ? '已关注' : '关注该问题';
            }
        }
    }
</script>
Route::post('/question/follower', function (Request $request) {
    return response()->json(['question'=> request('question')]);
})->middleware('api');
 <question-follow-button question="{ $question->id }"
                                                user="{ Auth::id() }"></question-follow-button>

我这边 也是同样问题, socket正常启动, 到了调用 事件监听器就卡住了, 504 请求超时, 真不知道怎么弄

/config/ broadcasting.php 这个文件里的配置改成redis 就出现超时情况,真不知道咋配置, 再说 laravel5.3 关于redis 的配置可不少, 广播你在laravel 5.3上测试过吗 ?刚测试5.2 是正常的 5.3 就是不行

 Redis::publish('test-channel',json_encode($data));

这个包是不是跟 laravel 5.3 不太兼容啊, 就卡到这儿 504 Gateway Time-out 错误! socket.js 运行正常!

我刚查了一下 是被占用了,现在可以访问了, 我用的VirtualBox 虚拟机 不是homestead

laravel 5.3
nodejs 6.9.1
"ioredis": "^2.5.0",
"socket.io": "^1.7.3"

~/redis $ node socket.js
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server._listen2 (net.js:1257:14)
    at listen (net.js:1293:10)
    at Server.listen (net.js:1389:5)
    at Object.<anonymous> (/Users/abdureshid/redis/socket.js:15:6)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

出现了以上报错, socket代码如下:

var http = require('http').Server();
var io = require('socket.io')(http);
var Redis = require('ioredis');
var redis = new Redis();

redis.subscribe('test-channel');

redis.on('message', function (channel, message) {
    console.log(channel + ':' + message);
});

http.listen(3000);

route 文件测试代码如下:

use Illuminate\Support\Facades\Redis;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('/', function () {
    $data = [
        'aNewMessage',
        'data'=>[
            'name'=>'test-name'
        ]
    ];
    Redis::publish('test-channel',json_encode($data));
});

不知道怎么解决 @jellybool

我想当天的一些数据 每天晚上00:00 的时候 自动计算保存到数据库或者文件里, 这个应该怎么做? 我翻了不少文档 不知道该怎么做才能自动运行? @jallyBool 希望帮个忙,谢谢!

我这边package 全部更新好了

FatalThrowableError in Client.php line 77:
Call to undefined function Qiniu\Http\curl_init()
in Client.php line 77
at Client::sendRequest(object(Request)) in Client.php line 13
at Client::get('http://uc.qbox.me/v1/query?ak=VpeOXJHlLLtzLoMzTssYAOHjIbZazc_bFZSk3SzS&bucket=test') in Zone.php line 178
at Zone->bucketHosts('VpeOXJHlLLtzLoMzTssYAOHjIbZazc_bFZSk3SzS', 'test') in Zone.php line 93
at Zone->getBucketHosts('VpeOXJHlLLtzLoMzTssYAOHjIbZazc_bFZSk3SzS', 'test') in Zone.php line 53
at Zone->getUpHosts('VpeOXJHlLLtzLoMzTssYAOHjIbZazc_bFZSk3SzS', 'test') in Auth.php line 97
at Auth->uploadToken('test') in QiNiuStorage.php line 38
at QiNiuStorage->store(object(UploadedFile), '/uploads/image/2017/03/16/980b65115abbea096cb18547ff7846b4.png') in Manager.php line 137
at Manager->__call('store', array(object(UploadedFile), '/uploads/image/2017/03/16/980b65115abbea096cb18547ff7846b4.png')) in StorageManager.php line 56
at StorageManager->upload(object(Request)) in UEditorController.php line 45
at UEditorController->serve(object(Request))
at call_user_func_array(array(object(UEditorController), 'serve'), array(object(Request))) in Controller.php line 55
at Controller->callAction('serve', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(UEditorController), 'serve') in Route.php line 189
at Route->runController() in Route.php line 144
at Route->run(object(Request)) in Router.php line 653
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Router.php line 655
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
at Router->dispatchToRoute(object(Request)) in Router.php line 607
at Router->dispatch(object(Request)) in Kernel.php line 268
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Debugbar.php line 51
at Debugbar->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 150
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53