有人可以"逐步","逐行"解释这段代码吗?我想了解更多关于Asynch代码以及Google如何加载他们的脚本,如何从用户"隐藏"javascrippt(我知道我无法隐藏它但至少让它像Google那样,不显示所有代码)一个档案)
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-xxxxxxxx-x', 'xxxxxx.com');
ga('send', 'pageview');
</script>
Run Code Online (Sandbox Code Playgroud) 有没有人知道用百分比指示器实现Angular 2+预加载器的良好解决方案(类似于Gmail的加载屏幕)?
我知道通常的方法是添加<div>内部我们的<app-root>风格,甚至可以添加CSS动画,一旦应用程序加载,它将被应用程序内容替换.
但是......我实际看的是显示动画启动画面(SVG或其他任何内容),在动画完成后,应该出现加载栏并显示进度状态.
在第一点,我正在考虑单独的splash组件,它将只是组件急切加载并从那里加载所有其他模块但是如果我将该组件映射到'/'如何在任何其他路由上显示它作为第一个(起始点).此外,这意味着必须已加载Angular主包,因此这不是一个好的选择.
很可能这个问题太宽泛而且不适合Stack Overflow,但我找不到任何好的解决方案.:(
有没有办法加载没有Angular的纯JavaScript,它将加载Angular并显示进度?还是其他(更好)的想法?
这必须是可以实现的,因为整个Gmail都是Angular应用程序而且它们拥有它:D
我正在尝试创建一个3步注册页面cakePHP.第一步是OK,它在db中插入数据,但第二步不起作用.有人可以帮忙吗?
这是我的控制器代码:
<?php
App::uses('Controller', 'Controller');
class UsersController extends AppController {
public $name = 'Users';
public function beforeFilter(){
parent::beforeFilter();
$this->Auth->allow('signup');
}
public function login(){
if($this->request->is('post')){
if($this->Auth->login()){
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Invalid username or password!', 'default', array('class' => 'errormsg'));
}
}
}
public function logout(){
$this->redirect($this->Auth->logout());
}
// SIGN UP ACTIONS
public function signup($step = null){
// SET STEP VARIABLE
$this->set('s', $step);
// STEP 1 - REGISTER
if(empty($step)){
if ($this->request->is('post')) {
if ($this->User->save($this->request->data)) {
$this->Session->write('regUser', $this->request->data['User']['email']);
// $this->Session->setFlash('The user has …Run Code Online (Sandbox Code Playgroud) 我有数组 $productsTop
(int) 0 => '6
(int) 1 => '4',
(int) 2 => '1',
(int) 3 => '2',
(int) 4 => '3',
(int) 5 => '5'
Run Code Online (Sandbox Code Playgroud)
其中 6 4 1 2 3 5 是产品表的 ID。我只想显示我的产品表中的 5 个产品,而不是按 ID ASC 或 DSC 订购,我想按 ID 订购它们,就像它们在 arrar 中订购的一样,因此它可以首先显示产品 ID 6,然后显示 ID 4...身份证 5。
任何人都可以请帮忙。
$productTop = [6,4,1,2,3,5];
$product = $this->Product->find('all', array(
'conditions'=>array('Product.id'=>$productTop),
'limit'=>5
));
Run Code Online (Sandbox Code Playgroud)
通过这种方式,它向我展示了所有产品,但按其 ID 订购,而不是向我展示:
6,4,1,2,3,5
Run Code Online (Sandbox Code Playgroud)
表明:
1,2,3,4,5,6
Run Code Online (Sandbox Code Playgroud) 如何保存关系的新用户?
用户模型:
public function profile(){
return $this->hasOne('Profile','id');
}
Run Code Online (Sandbox Code Playgroud)
档案型号:
protected $table = 'users_personal';
public function user(){
return $this->belongsTo('User','id');
}
Run Code Online (Sandbox Code Playgroud)
主功能:
$u = new User;
$u->username = $i['username'];
$u->email = $i['mail'];
$u->password = Hash::make( $i['password'] );
$u->type = 0;
$u->profile->id = $u->id;
$u->profile->name = $i['name'];
$u->profile->surname = $i['surname'];
$u->profile->address = $i['address'];
$u->profile->number = $i['strnum'];
$u->profile->city = $i['city'];
$u->profile->ptt = $i['ptt'];
$u->profile->mobile = $i['mobile'];
$u->profile->birthday = $i['year'].'-'.$i['mob'].'-'.$i['dob'];
$u->profile->newsletter = $i['news'];
$u->push();
Run Code Online (Sandbox Code Playgroud)
如果我这样做,我会收到一个错误:间接修改重载属性User :: $ profile无效
如何在创建新用户时保存用户配置文件?
php ×3
cakephp ×2
javascript ×2
angular ×1
cakephp-2.0 ×1
cakephp-2.1 ×1
eloquent ×1
laravel ×1
mysql ×1
preloader ×1