import { Component, ElementRef ,AfterViewInit} from '@angular/core';
exportclassAppComponent {
constructor(privateelementRef: ElementRef) {
}
ngAfterViewInit() {
let divEle =this.elementRef.nativeElement.querySelector('div');//获取第一个div
console.dir(divEle);
let div = doxcument.getElementById("div"); //获取id为‘div'的节点
}
}
import{ Component, ElementRef, ViewChild, AfterViewInit }from'@angular/core';
exportclassAppComponent{
@ViewChild('greet')
greetDiv: ElementRef;
ngAfterViewInit() {this.greetDiv.nativeElement.style.backgroundColor ='red'; }
}
<div #greet>hello world</div> //element的标识"#name",@ViewChild根据这个搜索元素
$scope.switchImage = function($event, value) {
3 $($event.target).on("mouseenter mouseleave",function(e) {
var w = $(this).width(); // 得到盒子宽度
var h = $(this).height();// 得到盒子高度
var x = (e.pageX - this.offsetLeft - (w / 2)) * (w > h ? (h / w) : 1);
// 获取x值
var y = (e.pageY - this.offsetTop - (h / 2)) * (h > w ? (w / h) : 1);
// 获取y值
var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
//direction的值为“0,1,2,3”分别对应着“上,右,下,左”
// 将点的坐标对应的弧度值换算成角度度数值
var dirName = new Array('上方','右侧','下方','左侧');
if(e.type == 'mouseenter' && direction == 1){
$(this).find('.profil-photo').html(dirName[direction]+'离开');
}else{
$(this).find('.profil-photo').html(dirName[direction]+'离开');
}
});
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有