如何实施Twilio Vue.js教程

发布于 2025-02-07 07:05:44 字数 1348 浏览 1 评论 0 原文

我尝试遵循本特里奥教程:

它是基于Laravel 6,我在2022年遇到了一些错误。 我已经通过添加AccessTokenController的完整名称空间来修复路线,

但是在教程中,我被要求“替换warey.blade.blade.php中的代码,

...
<script>
export default {
    name: 'video-chat',
    data: function () {
        return {
            accessToken: ''
        }
    },
    methods : {
        getAccessToken : function () {

            const _this = this
            const axios = require('axios')
            
            // Request a new token
            axios.get('/api/access_token')
                .then(function (response) {
                    _this.accessToken = response.data
                })
                .catch(function (error) {
                    console.log(error);
                })
                .then(function () {
                    console.log( _this.accessToken )
                });
        }
    },
    mounted : function () {
        console.log('Video chat room loading...')

        this.getAccessToken()
    }
}
</script>

但我认为作者犯了一个错误,实际上是指videochat.vue.vue.vue。文件内容。

但是粘贴的代码不起作用。我什至没有控制台日志。当我是vue.js的新手时,我想问社区可能是什么错误。

感谢您提前回答。

I try to follow the this Twilio Tutorial:
https://www.twilio.com/blog/create-video-conference-app-laravel-php-vue-js

As it is based on Laravel 6 I encounter some errors following in 2022.
I already fixed route by adding the full namespace of the AccessTokenController

However in the tutorial I get asked to "Replace the code in welcome.blade.php with the following:"

...
<script>
export default {
    name: 'video-chat',
    data: function () {
        return {
            accessToken: ''
        }
    },
    methods : {
        getAccessToken : function () {

            const _this = this
            const axios = require('axios')
            
            // Request a new token
            axios.get('/api/access_token')
                .then(function (response) {
                    _this.accessToken = response.data
                })
                .catch(function (error) {
                    console.log(error);
                })
                .then(function () {
                    console.log( _this.accessToken )
                });
        }
    },
    mounted : function () {
        console.log('Video chat room loading...')

        this.getAccessToken()
    }
}
</script>

However I think the author made a mistake and actually meant the VideoChat.vue file content.

But the pasted code does not work. I don't even get a console log. As I am novice to vue.js I would like to ask the community what the error might be.

Thank you for your answers in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有 2025-02-14 07:05:44

我认为您是对的,您粘贴的代码应该进入 videochat.vue

中welcome.blade.php 请确保已更换&lt; example-component&gt;&lt;/example-component&gt; ,用&lt; video>&lt; ;/video-chat&gt; 。然后,您应该在控制台中看到一些日志,并且应用程序获取访问令牌。

I think you're right, that the code you have pasted should go into VideoChat.vue.

In welcome.blade.php make sure you have replaced the <example-component></example-component> with <video-chat></video-chat>. Then you should see some logs in your console and the application fetch the access token.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文