tp5 controller与view通过fetch方法对应

目录文件

tp5 controller与view通过fetch方法对应_第1张图片

controller/Index.php

fetch方法默认访问application/index/view/index/index.html

fetch();
    }
}

view/index/index.html




    
    index


  

index下的index.html

运行结果如图

tp5 controller与view通过fetch方法对应_第2张图片

 

 

controller/article

fetch方法访问application/index/view/article/index.html

fetch('article/index');
    }
}

article/index.html




    
    article


article下的index.html

运行结果如图

tp5 controller与view通过fetch方法对应_第3张图片

 

配置文件引入样式

在index.php入口文件中

tp5 controller与view通过fetch方法对应_第4张图片

在index下添加配置文件config.php

  [
        '__PUBLIC__'=>SITE_URL.'/public/static/style/index',
      ]
    ];

此时__PUBLIC__的值设置为一个URL:http://localhost/php/Project/tp5/public/static/style/index

在对应路径下添加a.css文件

.mystyle{
    font-size: 30px;
    color: #953b39;
}

改变index/index.html中内容,引入css样式




    
    index
    


 __PUBLIC__

index下的index.html

此时再次访问则字体大小与颜色改变

tp5 controller与view通过fetch方法对应_第5张图片

你可能感兴趣的:(php)