我正在尝试使用以下技术创建一个单一页面的网站,角版8+ - WordPress
我找不到很多资源可以在WordPress上使用角8+。大多数可用的资源/解决方案都用于React或AngularJS。
到目前为止,我所发现的只是显示了如何使用带有/wp/wp/v2/post/终结点的get方法内部服务从WordPress网站获取数据。但是,我想要的是从零开始创建网站。
任何关于这方面的指导方针或想法都会很有帮助。我对此有很多疑问。
发布于 2020-01-28 06:33:49
您可以在代码中完成所有的手动操作,也可以找到某种插件来以这种方式提供帮助。在我的编码生涯中,我使用了这两种方法。
看看WP-NG是一个自动引导角应用程序的插件。通过管理页面激活模块并直接使用指令。我在2-3个项目中使用过这个。让我说清楚,这取决于你的要求,你想要实现什么。
以防万一,您仍然倾向于在更广泛的方面使用代码。试试这样的东西。
1)安装WordPress和新主题2)主题中的队列脚本3)设置主题4)创建AngularJS应用程序
var myapp = angular.module('myapp', []);
// set the configuration
myapp.run(['$rootScope', function($rootScope){
  // the following data is fetched from the JavaScript variables created by wp_localize_script(), and stored in the Angular rootScope
  $rootScope.dir = BlogInfo.url;
  $rootScope.site = BlogInfo.site;
  $rootScope.api = AppAPI.url;
}]);
// add a controller
myapp.controller('mycontroller', ['$scope', '$http', function($scope, $http) {
  // load posts from the WordPress API
  $http({
    method: 'GET',
    url: $scope.api, // derived from the rootScope
    params: {
      json: 'get_posts'
    }
  }).
  success(function(data, status, headers, config) {
    $scope.postdata = data.posts;
  }).
  error(function(data, status, headers, config) {
  });
}]);还有,你可以在这个博客上看看,我几天前在Quora上找到的,它很好读。是的,它的角度6,但可以在许多方面有所帮助。WordPress RestAPIs上的Range6blog
https://stackoverflow.com/questions/59941967
复制相似问题