先说下模板继承:
假定:在View文件夹中
-> Public 公共模块
—>base/header/top/footer 4个html文件
这下面base文件使用include引入其他3个文件,其中title用block标签,给个name属性,在不同的模板中可以实用block来重新定义title值,
block 标签,属性是main的可以,在不同的模板的写不同的内容
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title><block name="title">标题</block></title> </head> <body> <include file="Public/header" /> <include file="Public/top" /> <block name="main"></block> <include file="Public/footer" /> </body> </html>