资讯专栏INFORMATION COLUMN

laravel

GeekGhc / 2611人阅读

摘要:什么事是一种类库依赖关系管理器网址下载命令创建项目项目文件说明是压缩文件下载到哪个目录版本在中需要给和赋予权限路由,请求的一级分发者请求请求资源型请求会多几条的路由控制器,请求的二级分发者快速创建控制器查看路由列表控制器给视图层传参

1.什么事composer?
composer是一种php类库依赖关系管理器
网址:https://getcomposer.org/
2.composer下载laravel

composer create-project laravel/laravel --prefer-dist blog 5.2.*

composer命令 创建项目 laravel项目文件 说明是压缩文件 下载到哪个目录 laravel版本

在Linux中需要给storage和vender赋予权限

3.路由,请求的一级分发者

Route::get("/", "IndexController@index");  //get请求
Route::post("/", "IndexController@index"); // post请求
Route::resource("home", "HomeController@index"); // 资源型请求

resource会多几条的路由
4.控制器,请求的二级分发者
快速创建控制器

php artisan make:controller HomeController

5.查看路由列表

php artisan route:list

6.控制器给视图view层传参

return view("index")->with("name","tong");

$data = [
    "name"=>"tong",
    "age"=>18
];
return view("index",$data);

$name = "tong";
return view("index",compact("name"));    //等同于["name"=>"tong"]

7.blade模板引擎
7.1什么是blade模板引擎?blade是Laravel框架下的默认模板引擎
输出

{{$name}} => 
{{$name or "无名大侠"}} => 
@{{$name}}  //不解析

7.2控制流和循环
if

@if($anme)
    你好{{$anme}}.
@else
    你叫什么?
@endif    

foreach

    @foreach($name as $value)
  • {{$value}}
  • @endforeach

7.3子视图

//子视图 - Laravel教程<title>
将公共样式放在common目录中,然后引用@include("common.head")</pre>
<p>
<p>环境与部署<br>8.1 数据库</p>
<pre>首先看看项目根目录有没有.env文件,没有的话复制.env.example,名字叫做.env,里面存放一些全局的环境变量参数
DB::connection()->getDatabaseName(); //查看有没有链接成功</pre>
<p>8.2 session</p>
</p>
<p>8.3 环境文件</p>
<pre>注意:上传项目的时候一定要注意删除.env文件</pre>
<p>8.4 部署和开发模式切换<br>8.5 down/up</p>
<pre>比如我们的网站突然发生了一些大规模的攻击或一些其他的问题,造成我们的一些数据的丢失,数据完整性的问题,数据一致性的问题,总之就是一些比较严重的问题,以至于我们不得不停下来,首先给用户一个503页面,让用户知道我们的网站遭遇了一些问题正在抢修,什么时候恢复,或恢复时间不确定,给用户一个这样的页面,遇到这种情况,我们可以直接 php artisan down 给用户提示,等网站恢复后 php artisan up 让项目正常运行
</pre>
<p>9.eloquent--一种和数据库交互的机制,好用,优雅<br>快速创建model:php artisan make:model User</p>
<pre>protected $table = "user";//表名
protected $guarded = ["user_id"];//不被赋值的属性
protected $hidden;//隐藏数据,禁止查询
protected $primaryKey = "id";//主键
protected $fillable = ["name"];//那些属性可以被赋值
public $timestamps = false;关闭时间戳字段得添加
$model->findorFail();查询不到数据就报错
//查询数据
$this->all();

//添加数据
$data = ["useraname"=>"sssss","pwd"=>"sdasdsa"];
$model->fill($data_array());以数组的形式添加数据,异常强大不在$this->username = $data["username"];
$model->save();

//修改数据
$user= $model->find($id);
$user->username = "adsadasd";
$user->save();

//批量修改
$user = $this->where("age","<",18);
$user->update(["username"=>"adasda","age"=>60]);

///删除数据
$user = $this->find($id);
$user->delete();

//通过主键删除模型
AppFlight::destroy(1);
AppFlight::destroy([1, 2, 3]);
AppFlight::destroy(1, 2, 3);

//通过查询删除模型
$deletedRows = AppFlight::where("active", 0)->delete();

//添加额外约束
$flights = AppFlight::where("active", 1)
           ->orderBy("name", "desc")
           ->take(10)
           ->get();</pre>
<p>9.集合</p>
<pre>$user = new AppUser();
$users = $user->all();
dd($users);  //等同于var_dump($users);die;
$users->toArray();   //将集合变为数组

$arr = ["sss","ffffd"];
$collection = collect($arr);    //将数组变为集合,可以方便的使用结合中的方法
$data = $collection->all();   //则又可以获得数据的原型

$bool = $collection->contains("sss");//查看集合中有没有sss这个值,有的话返回true,没有返回false
$collection->has("sss");//查看集合中有没有叫sss的键
$collection->take(2);//取出集合中的前两个值,如果为负值,则从后往前取
</pre>
<p>10.操作用户产生的数据<br>10.1请求(requset)<br>10.1.1基础:获取用户提交的数据</p>
<pre>input::get("name"); //可以获取url路径中的值
Request::all(); //返回用户提交的所有数据
</pre>
<p>10.1.2请求实例</p>
<pre>Request::get("name");//接受用户输入的数据;可选的第二个参数,给它一个默认值
Request::query("name");//与get相似,但具有更强的选择性,固定接受地址栏中的数据,没有参数返回所有数据
Request::has("name");//查看用户提交的数据中是否有name键,并且不为空的时候,返回true;否则false
Request::exists("name");//查看用户提交的数据中是否存在name键
 
Request::only("name","age");//限制用户的输入,只接受name和age这两个参数
Requset::except("name","age");//与only()正好相反,除了name和age,其他的参数都接受
Requset::url();//返回网址(不带参数)
Requsett::fullUrl();//返回全部网址(带参数)
</pre>
<p>10.1.4请求历史</p>
<pre>当用户提交信息错误的时候,把用户填写的数据再返回去,提高用户体验度
Request::falsh();//用户数据处理失败后,保存之前提交的数据
Request::falshOnly();//同falsh()一样,只存某些数据
Request::falshExcept();//同falsh()一样,除了这几个数据,其他的数据都存储
Request::old();//提交失败返回后,在拿出之前用户的数据
</pre>
<p>10.1.5文件</p>
<pre>Request::file("myFile");//获取用户在请求中所包含的所有文件
Request::hasFile("myFile");//是否有上传文件,返回bool值
Request::file("myFile")->getSize();获取文件大小
Request::file("myFile")->getClientOriginalName();//获取客户端上传文件的名称
Request::file("myFile")->getClientOriginalExtension();获取客户端上传文件的后缀
<input type="file" name="myFile" multiple>  //可以让文件多选
</pre>
<p>11.会话:session</p>
<pre>会话用于储存用户和服务器之间的一个状态
Session:::all();//获取所有的session
Session::put($key,$value);/添加一个session
Session::get("username");//获取某个session
Session::has("username");//有没有名叫username的session
Session::forget("username");//销毁某个session
Session::pull();用一次之后就被销毁,可以在用户修改数据的时候,和falsh配合使用
</pre>
<p>12.会话配置</p>
<pre>在laravel中,session默认使用文件存储的,可对于一个真正跑在线上的项目来说,它对性能的要求是比较高的,尤其是大并发量的项目,所以说,一半我们能存在数据库,就存在数据库,因为文件的读取速度不比较慢,下面是具体过程
1.在.env中,修改 SESSION_DRIVER=database
2.生成从存储session的数据表:php artisan session:table
3.composer dump-autoload    重新生成框架的自动加载文件
4.php artisan migrate    执行数据迁移</pre>
<p>除了database,session还可以存储在cookie,memcache,redis中</p>
<p>13.数据验证</p>
<pre>public function create(){
  //接收数据
  $data = Request::all();
  //验证数据
  $validator = Validator::make($data,[
    "username"=>"required|min:4|max:10|unique:user",//username必填,最少4位,最多10位(between:4,10),user表中要唯一
    "pwd"=>"numeric|required"//pwd必须为数字,必填,,多个验证用‘|’隔断
  ]);

  //对验证失败做出相应
  if($validator->fails()){
    return $validator->errors();
  }
  //验证成功
  return "验证成功!";
}</pre>
<p>14.哈希hash</p>
<pre> //hash
Route::get("hashmake",function(){
  $password = Request::get("password");
  $hashPassword = Hash::make($password);
  Session::put("hashpassword",$hashPassword);
  return Session::get("hashpassword");
});
Route::get("hashcheck",function(){
  $inputpassword = Request::get("password");
  $hashpassword = Session::get("hashpassword");
  if(Hash::check($inputpassword,$hashpassword)){//第一个参数是输入的密码,第二个参数是哈希密码
    echo "密码输入正确";
  }else{
    echo "密码输入错误";
  }
});</pre>
<p>15.帮助函数<br>15.1帮助函数--array</p>
<pre>//head()返回数组中的第一个参数
$arr = ["one","two","three"];
head($arr);//one

//array_only()
$arr = ["one"=>"hou","two"=>"li","three"=>"zhao"];
return array_only($arr,["one","two"]);//只要数组中的one和two键的值
//["one"=>"hou","two"=>"li"]

//array_first()返回满足条件的第一个值
$arr1 = [1,2,3];
return array_first($arr1,function($key,$value){
  return $value>=2;
});
//2

//array_add($arr,$key,$value)向数组中添加值
$arr = ["one"=>"hou","two"=>"li","three"=>"zhao"];
return array_add($arr,"four","zhang");
//["one"=>"hou","two"=>"li","three"=>"zhao","four"=>"zhang"]

//array_except($arr,$arr_except)除了什么,返回数组中其他的值
$arr = ["one"=>"hou","two"=>"li","three"=>"zhao"];
return array_except($arr,["two"]);
//{"one":"hou","three":"zhao"}

//array_flatten将多为数组转化成以为数组
$arr = ["one"=>"hou","two"=>"li","three"=>["zhao","zhang"]];
return array_flatten($arr);
//["hou","li","zhao","zhang"]

//array_where();返回满足条件的参数
$arr = ["one"=>"hou","two"=>"li","three"=>["zhao","zhang"]];
return array_where($arr,function ($k,$v){
  return is_array($v);
});
//{"three":["zhao","zhang"]}

//array_last()返回数组中的最后一个值
$arr = ["one"=>"hou","two"=>"li","three"=>"zhao"];
return array_last($arr);
//zhao
</pre>
<p>15.2帮助函数--path</p>
<pre>app_path();//返回项目的路径
config_path();//返回配置路径
public_path();//返回public的路径
storage_path();//返回storage的路径(过程文件的储存目录)
</pre>
<p>15.3帮助函数--string</p>
<pre>str_plural($str);//某个英文单词的复数,非常智能,不是你所看到的那么简单
starts_with("asd","a");//该字符传是否以a开头,返回bool值
end_with("asd","d");//该字符传是否以d结尾,返回bool值
camel_case($str);//将字符串转化成驼峰式
class_basename("AppHttpControllersTestController");//只返回TestController
str_limit("abcd",3);//abc...   限制字符串的长度,超出后在字符串后加上‘...’
str_is("ab*","abcd");//相当于正则,判断支付穿是否满足于某种模式,第一个参数是条件,第二个参数是匹配的字符串,返回bool值</pre>           
               
                                           
                       
                 </div>
            
                     <div class="mt-64 tags-seach" >
                 <div class="tags-info">
                                                                                                                    
                         <a style="width:120px;" title="海外云主机" href="https://www.ucloud.cn/site/active/kuaijiesale.html?ytag=seo#global-uhost">海外云主机</a>
                                             
                         <a style="width:120px;" title="私有云" href="https://www.ucloudstack.com/?ytag=seo">私有云</a>
                                                                                                                                                 
                                      
                     
                    
                                                                                               <a style="width:120px;" title="LaravelS" href="https://www.ucloud.cn/yun/tag/LaravelS/">LaravelS</a>
                                                                                                           <a style="width:120px;" title="-laravel" href="https://www.ucloud.cn/yun/tag/-laravel/">-laravel</a>
                                                                                                           <a style="width:120px;" title="laravel" href="https://www.ucloud.cn/yun/tag/laravel/">laravel</a>
                                                                                                           <a style="width:120px;" title="laravel cdn" href="https://www.ucloud.cn/yun/tag/laravel cdn/">laravel cdn</a>
                                                         
                 </div>
               
              </div>
             
               <div class="entry-copyright mb-30">
                   <p class="mb-15"> 文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。</p>
                 
                   <p>转载请注明本文地址:https://www.ucloud.cn/yun/30588.html</p>
               </div>
                      
               <ul class="pre-next-page">
                 
                                  <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/30587.html">上一篇:Flash Message For Laravel5</a></li>  
                                                
                                       <li class="ellipsis"><a class="hpf" href="https://www.ucloud.cn/yun/30589.html">下一篇:一个 PHPer 第一次用 Koa2 写 Node.js 的心路历程</a></li>
                                  </ul>
              </div>
              <div class="about_topicone-mid">
                <h3 class="top-com-title mb-0"><span data-id="0">相关文章</span></h3>
                <ul class="com_white-left-mid atricle-list-box">
                             
                                                                    <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/21270.html"><b><em>Laravel</em>不权威导航</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:版微信第三方登陆包括微信微博等等,查看支持列表扩展好用的图片处理,也方便使用百度版百度版支付集合,包含支付宝等支付宝在的封装各国语言包,包含简体中文生成二维码工具,亲测好用未完大家可以向我推荐,直接在本文下留言即可。

Laravel不权威导航
Hi 这里是Roy整理的Laravel相关索引,希望能帮到大家showImg(http://static.segmentfault.com/bu...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-1228.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/12/small_000001228.jpg" alt=""><span class="layui-hide64">focusj</span></a>
                                    <time datetime="">2019-06-27 11:48</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/30678.html"><b>下载量最高的「50 」个 <em>Laravel</em> 扩展包</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:简介另一个令人喜欢的地方,是拥有活跃的开发者社区,而活跃的开发者社区带来的,是繁华的扩展包生态该项目统计了目前下载量最高的个扩展包。记得哟相信下面这些扩展包会让你的编码更加高效。排名下载量排名包地址下载次数描述图片处理。

简介
Laravel 另一个令人喜欢的地方,是拥有活跃的开发者社区,而活跃的开发者社区带来的,是繁华的扩展包生态 ———— @Summer
该项目统计了目前 pack...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-596.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/05/small_000000596.jpg" alt=""><span class="layui-hide64">liaorio</span></a>
                                    <time datetime="">2019-07-01 12:25</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/20954.html"><b><em>laravel</em> package收集</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:查找保存下载用搭建自己的缓存仓库权限管理的好选择基于封装的后台管理系统,支持手机和端访问支付宝风格的验证器后台系统微信接口的部署脚本开发的博客系统百度推送自动记录用户行为扩展一个项目管理系统根据生成对应导航的状态

1.debug https://github.com/barryvdh/l...
showImg(https://segmentfault.com/img/bVmhWL);
...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-1611.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/16/small_000001611.jpg" alt=""><span class="layui-hide64">psychola</span></a>
                                    <time datetime="">2019-06-27 11:14</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/28928.html"><b>Git多分支平行发展(一个仓库包含多个不同的项目)</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:建立并切换到本地分支沐沐沐也可以直接用删除本地仓库里的所有文件除了的文件夹,然后推送沐沐沐这个时候,远程仓库的分支便和本地仓库的分支一样都是空白的,这样就可以随心所欲的推送了。

背景
最近在用laravel开发微信小程序的接口,因为服务器PHP版本的问题,分别用了laravel 5.6(php 7.1,开发环境)  和 laravel 5.4 (php 5.6,服务器环境),开发完成后...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-1078.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/10/small_000001078.jpg" alt=""><span class="layui-hide64">MonoLog</span></a>
                                    <time datetime="">2019-07-01 10:13</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/31203.html"><b><em>Laravel</em> 5.5 升级到 5.5.42 后遇到的 Cookie 序列化问题</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:查阅官方文档后得知,新版为了防止对象的序列化反序列化漏洞被利用,不再对值进行自动的序列化和反序列化处理。举个栗子更新到后,因为不再自动对值进行序列化处理,而只能加密字符串数据,这个时候程序就会抛出错误。

最近手残升级了项目里 Laravel 的小版本号(v5.5.39 => v5.5.45),这不升级则已,一升级就出了问题!
Sentry 平台上提示错误:openssl_encrypt...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-301.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/03/small_000000301.jpg" alt=""><span class="layui-hide64">jollywing</span></a>
                                    <time datetime="">2019-07-01 12:40</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                                       <li>
                                                <div class="atricle-list-right">
                          <h2 class="ellipsis2"><a class="hpf" href="https://www.ucloud.cn/yun/22021.html"><b>1. <em>Laravel</em>的初始化安装 - <em>Laravel</em>从零开始教程</b></a></h2>
                                                     <p class="ellipsis2 good">摘要:要学习那么第一步就是要在我们的开发机上安装并运行,首先我们会先安装再使用框架提供的安装小工具,通过使用就能生成我们的工程了。在的官方网站上的文档中已经很详细的介绍了如何安装不过文档可能讲解的并不是那么的细致。从零开始学系列目录地址

要学习Laravel,那么第一步就是要在我们的开发机上安装并运行Laravel,首先我们会先安装composer,再使用laravel框架提供的安装小工具,...</p>
                                                   
                          <div class="com_white-left-info">
                                <div class="com_white-left-infol">
                                    <a href="https://www.ucloud.cn/yun/u-272.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/02/small_000000272.jpg" alt=""><span class="layui-hide64">baukh789</span></a>
                                    <time datetime="">2019-06-27 14:47</time>
                                    <span><i class="fa fa-commenting"></i>评论0</span> 
                                    <span><i class="fa fa-star"></i>收藏0</span> 
                                </div>
                          </div>
                      </div>
                    </li> 
                                                                           
                </ul>
              </div>
              
               <div class="topicone-box-wangeditor">
                  
                  <h3 class="top-com-title mb-64"><span>发表评论</span></h3>
                   <div class="xcp-publish-main flex_box_zd">
                                      
                      <div class="unlogin-pinglun-box">
                        <a href="javascript:login()" class="grad">登陆后可评论</a>
                      </div>                   </div>
               </div>
              <div class="site-box-content">
                <div class="site-content-title">
                  <h3 class="top-com-title mb-64"><span>0条评论</span></h3>   
                </div> 
                      <div class="pages"></ul></div>
              </div>
           </div>
           <div class="layui-col-md4 layui-col-lg3 com_white-right site-wrap-right">
              <div class=""> 
                <div class="com_layuiright-box user-msgbox">
                    <a href="https://www.ucloud.cn/yun/u-526.html"><img src="https://www.ucloud.cn/yun/data/avatar/000/00/05/small_000000526.jpg" alt=""></a>
                    <h3><a href="https://www.ucloud.cn/yun/u-526.html" rel="nofollow">GeekGhc</a></h3>
                    <h6>男<span>|</span>高级讲师</h6>
                    <div class="flex_box_zd user-msgbox-atten">
                     
                                                                      <a href="javascript:attentto_user(526)" id="attenttouser_526" class="grad follow-btn notfollow attention">我要关注</a>
      
                                                                                        <a href="javascript:login()" title="发私信" >我要私信</a>
                     
                                            
                    </div>
                    <div class="user-msgbox-list flex_box_zd">
                          <h3 class="hpf">TA的文章</h3>
                          <a href="https://www.ucloud.cn/yun/ut-526.html" class="box_hxjz">阅读更多</a>
                    </div>
                      <ul class="user-msgbox-ul">
                                                  <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/122766.html">pq.hosting:新上荷兰独立服务器,月付€150起</a></h3>
                            <p>阅读 855<span>·</span>2021-10-27 14:15</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/122720.html">cloudcone:黑色星期五,美国VPS:14.2美元/年起,支持支付宝,洛杉矶MC机房</a></h3>
                            <p>阅读 2613<span>·</span>2021-10-25 09:45</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/118737.html">RAKsmart:注册即送10美金新人红包,可新购/续费/升级服务器等!</a></h3>
                            <p>阅读 1792<span>·</span>2021-09-02 09:45</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/117342.html">2-清除浮动</a></h3>
                            <p>阅读 3182<span>·</span>2019-08-30 15:55</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/113516.html">JavaScript 工作原理之十五-类和继承及 Babel 和 TypeScript 代码转换探秘</a></h3>
                            <p>阅读 1682<span>·</span>2019-08-29 16:05</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/111105.html">css3 attr 简单介绍和实例</a></h3>
                            <p>阅读 3034<span>·</span>2019-08-28 18:13</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/109923.html">vue-cli3中vue.config.js配置</a></h3>
                            <p>阅读 3021<span>·</span>2019-08-26 13:58</p></li>
                                                       <li><h3 class="ellipsis"><a href="https://www.ucloud.cn/yun/108044.html">前端如何在本地起临时服务器?</a></h3>
                            <p>阅读 341<span>·</span>2019-08-26 12:01</p></li>
                                                
                      </ul>
                </div>

                   <!-- 文章详情右侧广告-->
              
  <div class="com_layuiright-box">
                  <h6 class="top-com-title"><span>最新活动</span></h6> 
           
         <div class="com_adbox">
                    <div class="layui-carousel" id="right-item">
                      <div carousel-item>
                                                                                                                       <div>
                          <a href="https://www.ucloud.cn/site/active/kuaijiesale.html?ytag=seo"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/zYeoGo8M.png" alt="云服务器">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/active/gpu.html?ytag=seo"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/29R6rrOS.png" alt="GPU服务器">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/active/kuaijiesale.html?ytag=seo#global-uhost"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/FFBiRWaT.png" alt="海外云主机">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloudstack.com/?ytag=seo"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/VEgKnwRX.png" alt="私有云">                                 
                          </a>
                        </div>
                                                <div>
                          <a href="https://www.ucloud.cn/site/active/new/uhybrid.html?ytag=seo#datacenter"  rel="nofollow">
                            <img src="https://www.ucloud.cn/yun/data/attach/240506/Z1o6CMPK.png" alt="服务器托管">                                 
                          </a>
                        </div>
                                                                   
                    
                        
                      </div>
                    </div>
                      
                    </div>                    <!-- banner结束 -->
              
<div class="adhtml">

</div>
                <script>
                $(function(){
                    $.ajax({
                        type: "GET",
                                url:"https://www.ucloud.cn/yun/ad/getad/1.html",
                                cache: false,
                                success: function(text){
                                  $(".adhtml").html(text);
                                }
                        });
                    })
                </script>                </div>              </div>
           </div>
        </div>
      </div> 
    </section>
    <!-- wap拉出按钮 -->
     <div class="site-tree-mobile layui-hide">
      <i class="layui-icon layui-icon-spread-left"></i>
    </div>
    <!-- wap遮罩层 -->
    <div class="site-mobile-shade"></div>
    
       <!--付费阅读 -->
       <div id="payread">
         <div class="layui-form-item">阅读需要支付1元查看</div>  
         <div class="layui-form-item"><button class="btn-right">支付并查看</button></div>     
       </div>
      <script>
      var prei=0;

       
       $(".site-seo-depict pre").each(function(){
          var html=$(this).html().replace("<code>","").replace("</code>","").replace('<code class="javascript hljs" codemark="1">','');
          $(this).attr('data-clipboard-text',html).attr("id","pre"+prei);
          $(this).html("").append("<code>"+html+"</code>");
         prei++;
       })
           $(".site-seo-depict img").each(function(){
             
            if($(this).attr("src").indexOf('data:image/svg+xml')!= -1){
                $(this).remove();
            }
       })
     $("LINK[href*='style-49037e4d27.css']").remove();
       $("LINK[href*='markdown_views-d7a94ec6ab.css']").remove();
layui.use(['jquery', 'layer','code'], function(){
  $("pre").attr("class","layui-code");
      $("pre").attr("lay-title","");
       $("pre").attr("lay-skin","");
  layui.code(); 
       $(".layui-code-h3 a").attr("class","copycode").html("复制代码 ").attr("onclick","copycode(this)");
      
});
function copycode(target){
    var id=$(target).parent().parent().attr("id");
  
                  var clipboard = new ClipboardJS("#"+id);

clipboard.on('success', function(e) {


    e.clearSelection();
    alert("复制成功")
});

clipboard.on('error', function(e) {
    alert("复制失败")
});
}
//$(".site-seo-depict").html($(".site-seo-depict").html().slice(0, -5));
</script>
  <link rel="stylesheet" type="text/css" href="https://www.ucloud.cn/yun/static/js/neweditor/code/styles/tomorrow-night-eighties.css">
    <script src="https://www.ucloud.cn/yun/static/js/neweditor/code/highlight.pack.js" type="text/javascript"></script>
    <script src="https://www.ucloud.cn/yun/static/js/clipboard.js"></script>

<script>hljs.initHighlightingOnLoad();</script>

<script>
    function setcode(){
        var _html='';
    	  document.querySelectorAll('pre code').forEach((block) => {
        	  var _tmptext=$.trim($(block).text());
        	  if(_tmptext!=''){
        		  _html=_html+_tmptext;
        		  console.log(_html);
        	  }
    		 
    		  
    		 
      	  });
    	 

    }

</script>

<script>
function payread(){
  layer.open({
      type: 1,
      title:"付费阅读",
      shadeClose: true,
      content: $('#payread')
    });
}
// 举报
function jupao_tip(){
  layer.open({
      type: 1,
      title:false,
      shadeClose: true,
      content: $('#jubao')
    });

}
$(".getcommentlist").click(function(){
var _id=$(this).attr("dataid");
var _tid=$(this).attr("datatid");
$("#articlecommentlist"+_id).toggleClass("hide");
var flag=$("#articlecommentlist"+_id).attr("dataflag");
if(flag==1){
flag=0;
}else{
flag=1;
//加载评论
loadarticlecommentlist(_id,_tid);
}
$("#articlecommentlist"+_id).attr("dataflag",flag);

})
$(".add-comment-btn").click(function(){
var _id=$(this).attr("dataid");
$(".formcomment"+_id).toggleClass("hide");
})
$(".btn-sendartcomment").click(function(){
var _aid=$(this).attr("dataid");
var _tid=$(this).attr("datatid");
var _content=$.trim($(".commenttext"+_aid).val());
if(_content==''){
alert("评论内容不能为空");
return false;
}
var touid=$("#btnsendcomment"+_aid).attr("touid");
if(touid==null){
touid=0;
}
addarticlecomment(_tid,_aid,_content,touid);
})
 $(".button_agree").click(function(){
 var supportobj = $(this);
         var tid = $(this).attr("id");
         $.ajax({
         type: "GET",
                 url:"https://www.ucloud.cn/yun/index.php?topic/ajaxhassupport/" + tid,
                 cache: false,
                 success: function(hassupport){
                 if (hassupport != '1'){






                         $.ajax({
                         type: "GET",
                                 cache:false,
                                 url: "https://www.ucloud.cn/yun/index.php?topic/ajaxaddsupport/" + tid,
                                 success: function(comments) {

                                 supportobj.find("span").html(comments+"人赞");
                                 }
                         });
                 }else{
                	 alert("您已经赞过");
                 }
                 }
         });
 });
 function attenquestion(_tid,_rs){
    	$.ajax({
    //提交数据的类型 POST GET
    type:"POST",
    //提交的网址
    url:"https://www.ucloud.cn/yun/favorite/topicadd.html",
    //提交的数据
    data:{tid:_tid,rs:_rs},
    //返回数据的格式
    datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
    //在请求之前调用的函数
    beforeSend:function(){},
    //成功返回之后调用的函数
    success:function(data){
    	var data=eval("("+data+")");
    	console.log(data)
       if(data.code==2000){
    	layer.msg(data.msg,function(){
    	  if(data.rs==1){
    	      //取消收藏
    	      $(".layui-layer-tips").attr("data-tips","收藏文章");
    	      $(".layui-layer-tips").html('<i class="fa fa-heart-o"></i>');
    	  }
    	   if(data.rs==0){
    	      //收藏成功
    	      $(".layui-layer-tips").attr("data-tips","已收藏文章");
    	      $(".layui-layer-tips").html('<i class="fa fa-heart"></i>')
    	  }
    	})
    	 
       }else{
    	layer.msg(data.msg)
       }


    }   ,
    //调用执行后调用的函数
    complete: function(XMLHttpRequest, textStatus){
     	postadopt=true;
    },
    //调用出错执行的函数
    error: function(){
        //请求出错处理
    	postadopt=false;
    }
 });
}
</script>
<footer>
        <div class="layui-container">
            <div class="flex_box_zd">
              <div class="left-footer">
                    <h6><a href="https://www.ucloud.cn/"><img src="https://www.ucloud.cn/yun/static/theme/ukd//images/logo.png" alt="UCloud (优刻得科技股份有限公司)"></a></h6>
                    <p>UCloud (优刻得科技股份有限公司)是中立、安全的云计算服务平台,坚持中立,不涉足客户业务领域。公司自主研发IaaS、PaaS、大数据流通平台、AI服务平台等一系列云计算产品,并深入了解互联网、传统企业在不同场景下的业务需求,提供公有云、混合云、私有云、专有云在内的综合性行业解决方案。</p>
              </div>
              <div class="right-footer layui-hidemd">
                  <ul class="flex_box_zd">
                      <li>
                        <h6>UCloud与云服务</h6>
                         <p><a href="https://www.ucloud.cn/site/about/intro/">公司介绍</a></p>
                         <p><a href="https://zhaopin.ucloud.cn/" >加入我们</a></p>
                         <p><a href="https://www.ucloud.cn/site/ucan/onlineclass/">UCan线上公开课</a></p>
                         <p><a href="https://www.ucloud.cn/site/solutions.html" >行业解决方案</a></p>                                                  <p><a href="https://www.ucloud.cn/site/pro-notice/">产品动态</a></p>
                      </li>
                      <li>
                        <h6>友情链接</h6>                                             <p><a href="https://www.compshare.cn/?ytag=seo">GPU算力平台</a></p>                                             <p><a href="https://www.ucloudstack.com/?ytag=seo">UCloud私有云</a></p>
                                             <p><a href="https://www.surfercloud.com/">SurferCloud</a></p>                                             <p><a href="https://www.uwin-link.com/">工厂仿真软件</a></p>                                             <p><a href="https://pinex.it/">Pinex</a></p>                                             <p><a href="https://www.picpik.ai/zh">AI绘画</a></p>
                                             
                      </li>
                      <li>
                        <h6>社区栏目</h6>
                         <p><a href="https://www.ucloud.cn/yun/column/index.html">专栏文章</a></p>
                     <p><a href="https://www.ucloud.cn/yun/udata/">专题地图</a></p>                      </li>
                      <li>
                        <h6>常见问题</h6>
                         <p><a href="https://www.ucloud.cn/site/ucsafe/notice.html" >安全中心</a></p>
                         <p><a href="https://www.ucloud.cn/site/about/news/recent/" >新闻动态</a></p>
                         <p><a href="https://www.ucloud.cn/site/about/news/report/">媒体动态</a></p>                                                  <p><a href="https://www.ucloud.cn/site/cases.html">客户案例</a></p>                                                
                         <p><a href="https://www.ucloud.cn/site/notice/">公告</a></p>
                      </li>
                      <li>
                          <span><img src="https://static.ucloud.cn/7a4b6983f4b94bcb97380adc5d073865.png" alt="优刻得"></span>
                          <p>扫扫了解更多</p></div>
            </div>
            <div class="copyright">Copyright © 2012-2023 UCloud 优刻得科技股份有限公司<i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/">沪公网安备 31011002000058号</a><i>|</i><a rel="nofollow" href="http://beian.miit.gov.cn/"></a> 沪ICP备12020087号-3</a><i>|</i> <script type="text/javascript" src="https://gyfk12.kuaishang.cn/bs/ks.j?cI=197688&fI=125915" charset="utf-8"></script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?290c2650b305fc9fff0dbdcafe48b59d";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DZSMXQ3P9N"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-DZSMXQ3P9N');
</script>
<script>
(function(){
var el = document.createElement("script");
el.src = "https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?99f50ea166557aed914eb4a66a7a70a4709cbb98a54ecb576877d99556fb4bfc3d72cd14f8a76432df3935ab77ec54f830517b3cb210f7fd334f50ccb772134a";
el.id = "ttzz";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(el, s);
})(window)
</script></div> 
        </div>
    </footer>
</body>
<script src="https://www.ucloud.cn/yun/static/theme/ukd/js/common.js"></script>
<<script type="text/javascript">
$(".site-seo-depict *,.site-content-answer-body *,.site-body-depict *").css("max-width","100%");
</script>
</html>