在wordpress中整合vue


为什么会有此需求

有时候想在wordpress文章中插入部分UI逻辑,如果单独去写个页面太麻烦了,而且主题风格也要处理,所以做成往文章内容里面填充用vue写的代码就行了,做小工具高产似母猪!

怎么实现

  • 选中一个主题模板,在page-templates创建一个vue的php模板
  • 创建一个header并引入css
  • 创建一个footer引入vue.js
  • 然后在wp后台以这个模板创建文章,将vue代码贴入就可以了

模板大致如下

<?php
/**
 * Template Name: Vue Template
 *
 * The template for the Vue page.
 *
 */
get_vue_header(); ?>
<div class="row">
    <main id="main" class="class of the theme">

        <?php while ( have_posts() ) : the_post(); ?>
            <?php get_vue_content(); ?>
        <?php endwhile; // End of the loop. ?>
    </main><!-- #main -->
</div>
<?php get_sidebar(); ?>
<?php get_vue_footer(); ?>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://11000011.com/?id=9

« 上一篇 下一篇 »
«    2026年7月    »
12345
6789101112
13141516171819
20212223242526
2728293031

控制面板

您好,欢迎到访网站!
  查看权限
«    2026年7月    »
12345
6789101112
13141516171819
20212223242526
2728293031

控制面板

您好,欢迎到访网站!
  查看权限
您是本站第22699名访客 今日有0篇新文章