在Framework7,Vue中加载AJAX

时间:2018-07-17 11:55:17

标签: vue.js phonegap html-framework-7

我是Framework7的新手,并且想要构建一个相当简单的移动应用程序-位置列表,这些位置的详细页面(其中显示了一些壁画)以及地图和关于页面。我目前的计划是通过PhoneGap Build进行发布,因为这似乎是一种快速简便的部署方式。

我使用phonegap-framework7-vue template创建了我的应用。也许对于这样一个简单的应用程序来说过于矫kill过正,但似乎比从头开始构建它要好。

我想通过AJAX(最终通过sqlite)加载地点列表,但无法弄清楚如何/何时进行以及如何访问主应用程序。我的Murals.vue文件具有模板和以下脚本,但未加载,因为app.request未定义。我已经尝试过“ framework7”,“ Framework7”,并将其移到mount()调用之外,但是感觉就像是在猜测。有什么建议吗?谢谢!

<script>
import F7List from "framework7-vue/src/components/list";

let dataURL = 'https://jsonplaceholder.typicode.com/posts'; // returns some json
export default {
    name: 'Murals',
    components: {F7List},
    mounted() { // when the Vue app is booted up, this is run automatically.
        app.request.get(dataURL, function (data) {
            console.log(data);
        });

    },

    data () {
        return {
            title: 'Murals'
        };
    }
};
</script>

1 个答案:

答案 0 :(得分:2)

您的代码几乎正确! 要使用vue访问F7应用实例,您必须使用this.$f7.request而不是app.request