[Vuejs]-Framework7 routes, load page from existing JSON string

0👍

Found a solution, my working code snippet is below. I used the same async section and converted the array output to a string using toString(). Only appears to work in the async section.
Can now load up the JSON for everything at the start, one JSON call.

Maybe will help someone else with Framework7. Good Luck!

{
  path: '/article/:article_id/',
  async: function (routeTo, routeFrom, resolve, reject) {

    // Do we already have the JSON for the page?
    if (typeof window.TodayJsonDB[routeTo.params.article_id]['html'] != "undefined") {
      resolve({
        content: (window.TodayJsonDB[routeTo.params.article_id]['html'].toString()),
      });
    }
    else{
      // Try and get it
      this.app.request.json('/__php/json1.php', { one: 1, article_id: routeTo.params.article_id }, function (data) {
        resolve(
            {
              content: data['article'][0]['article_html'],
            },
        );
      });
    }
  }

Leave a comment