首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Vue从Get php获取值

Vue从Get php获取值
EN

Stack Overflow用户
提问于 2017-11-05 14:48:46
回答 1查看 80关注 0票数 0

我有这个是为了得到userType

代码语言:javascript
运行
复制
<?php echo $userType = $_GET['user_type']?>;

我想将$userType初始化为Vue varibale,如下所示,或者使用任何简单的方法

代码语言:javascript
运行
复制
var ArtificialInsemination = new Vue({

    el:'#ArtificialInsemination',
    data: {
        url:'http://localhost/dairyweb/dairyfarm/index.php',
        artificialInseminationRecords: [],
        cowId: '',
        aiNo: '',
        sessession:'',
        user:$userType

    },
EN

回答 1

Stack Overflow用户

发布于 2017-11-05 15:12:23

在Vue中,你可以像这样抓取url参数:

代码语言:javascript
运行
复制
this.$route.query.user_type

假设您的url是这样的:

代码语言:javascript
运行
复制
http:://example.com?user_type=exampletype

我还假设您需要导入vuerouter,但我不能百分之百确定。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47118968

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档