English 中文(简体)
如何添加使用php的有活力的元件
原标题:How to Add Dynamic Meta tags Using php

I Fetch Data From Laravel AP and I 我想显示动态的元标题和描述,但当我为检查内容设定动态数据时,它显示了动态的价值观,但没有在网页上加以更新,在社会媒体中,如应用、面貌相等,也没有显示动态的所有权和描述。

这里是我的法典。

<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="theme-color" content="#084594" />
<meta property="og:title" id= metaTitle  content="Static Title">
<meta property="og:description" id= metaDescription  content="Static Description">

现在,我是利用Jquery来改变它。

<script>
$(document).ready(function() {
  const API = "<?= API ?>";
  $( #metaTitle ).attr( content , Dynamic Title )
  $( #metaDescription ).attr( content , Dynamic Description )
  function getCategory() {
   
    $.ajax({
      type: "get",
      url: `${API}/all_category`,
      success: function(response) {
        console.log("responseCat", response.category);
        $.each(response.category, function(key, item) {
          let cat = item.name.split(   )[0];
          $("#filter").append(
            `<li data-filter=".${cat}"><a href="#">${item.name}</a></li>`
          );
        });
        isotopFilter();
      },
    });
  }

  function getPortfolio() {
    $.ajax({
      type: "get",
      url: `${API}/all_portfolios`,
      success: function(response) {
        console.log("responseCat", response.portfolio);
        $.each(response.portfolio, function(key, item) {
          let cat = item.category.split(   )[0];
          let url_title = item.title.toLowerCase().replace(/[ ().]/g,  - );
          url_title = url_title.replace( -- ,  - );
          $(".masonry_wrapper").append(
            `<div class="col-md-4 col-sm-6 flex-active item ${cat}"><div class="tutorial_card"> <div class="service-content"> <a href="portfolio/${url_title}" > <h3>${item.title}</h3></a > </div><div class="read"> <a href="portfolio/${url_title}" class="btn btn-default" >View Portfolio</a > </div></div></div`
          );
        });
        isotopFilter();
      },
    });
  }

  
  getCategory();
  getPortfolio();
});

But It is showing Static Title And Description in ctrl + u Page Source code But In Inspect Elements It change With Dynamic Title And Description. And Also When Share Page It Shows Static Title And Description

问题回答

正如评论中已经指出的那样,大多数社会媒体和机器人并不关心clientside。 改动(Javascript在客户计算机上执行)。

你们需要使用PHP在serverside上设定计量财产。

我在拉韦斯-武伊项目中采用了Npm包@vueuse/head 。

n @vueuse/head

Laravel是一个强大的PHP框架,它支持了发展,而Vue.js, 民众的Java 字典框架,在创造互动的前端经验方面shin。 将这些技术与“@vueuse/head Pack”结合起来,使你能够有效管理有活力的元件。

本条中的成文法:

https://www.bitkaleido.com/blog/dynamic-meta-tags-in-laravel-vue-seo-optimized-3





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签