帖子
帖子
用户
博客
课程
显示全部楼层
7
帖子
1
勋章
73
Y币

[多端开发] 为什么YonStudio使用后端函数获取的数据可以在本机上实时...

[复制链接]
发表于 2024-4-20 11:05:19
为什么YonStudio使用后端函数获取的数据可以在本机上实时预览但无法在真机上显示
YonStudio只是一个编辑器,具体功能需要你自己调试哦,你代码怎么写的。
代码咋写的
7
帖子
1
勋章
73
Y币
  1. <template>
  2.     <safe-area class="page">
  3.         <scroll-view>
  4.             <list />
  5.             <addList />
  6.             <add />
  7.             <text>22222222222</text>
  8.         </scroll-view>

  9.     </safe-area>
  10. </template>
  11. <script>
  12. import '../../components/list.stml';
  13. import '../../components/addList.stml';
  14. import '../../components/add.stml';
  15. export default {
  16.     name: 'index',
  17.     apiready() { //like created
  18.     },
  19.     data() {
  20.         return {};
  21.     },
  22.     methods: {}
  23. };
  24. </script>
  25. <style>
  26. .page {
  27.     height: 100%;
  28.     background-color: aquamarine;
  29. }
  30. </style>
复制代码




<template>
        <view class="page">
                <view class="wrap" v-for="p in plist" :key="p.id">
                        <text>111111</text>
                        <text class="pno">编号{{p.pno}}</text>
                        <text class="color">颜色{p.color}</text>
                        <text class="pname">名称{p.pname}</text>
                        <text class="weight">重量{p.weight}</text>
                </view>
        </view>
</template>
<script>
export default {
        name: 'list',
        installed(){
                //发送请求
                //http://127.0.0.1:8080/User/
                api.ajax({
                        url:'http://127.0.0.1:8080/User/',
                        methods:'get'
                }, (plist, err) =>{
                        if(plist){
                                this.data.plist=plist.data
                                console.log(plist)
                        }else{
                                 console.log(err)
                        }
                })
        },
        apiready(){//like created

        },
        data() {
                return{
                        plist: []
                }
        },
        methods: {

        }
}
</script>
<style>
        .page {
                height: 100%;
        }
</style>
7
帖子
1
勋章
73
Y币
本帖最后由 BIP289437 于 2024-4-20 14:15 编辑

66235cbdd809b.png 66235c92bb084.png
66235ceec6a68.png
0
帖子
2
勋章
1079
Y币
127.0.0.1是相对域名,等于是本机的IP,你在电脑端因为服务端和PC是一体的,所以有效,在手机端无效
您需要登录后才可以回帖 登录

本版积分规则