var ipAddr;
//device.ip
var interfaces = os.networkInterfaces();
var interfaceNames = Object.keys(interfaces);
for (var name in interfaceNames) {
if (interfaceNames.hasOwnProperty(name)) {
var addrs = interfaces[interfaceNames[name]];
for (var add in addrs) {
if (addrs[add].netmask) {
//node 0.12 or better
if (!addrs[add].internal && addrs[add].family == 'IPv4') {
if (ip.isEqual(ip.mask(addrs[add].address,addrs[add].netmask),ip.mask(device.ip,addrs[add].netmask))) {
ipAddr = addrs[add].address;
break;
}
}
} else {
//node 0.10 not great but best we can do
if (!addrs[add].internal && addrs[add].family == 'IPv4') {
ipAddr = addrs[add].address;
break;
}
}
}
if (ipAddr) {
break;
}
}
}
var callback_url = 'http://' + ipAddr + ':' + settings.uiPort;
if (settings.httpAdminRoot) {
callback_url += settings.httpAdminRoot;
}
我正在使用bootstrap网格系统来实现这一点,但表单部分太宽 我无法弄清楚如何改变宽度,有什么方法可以解决这个问题吗?
答案 0 :(得分:0)
import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: 'textarea[reAutoWrap]',
})
export class AutoWrapDirective {
private readonly textarea: HTMLTextAreaElement;
constructor(el: ElementRef) {
this.textarea = el.nativeElement;
}
@HostListener('input') onInput() {
this.resize();
}
@HostListener('window:resize') onChange() {
this.resize();
}
private resize() {
this.textarea.rows = 1;
if (this.textarea.scrollHeight > this.textarea.clientHeight)
this.textarea.rows = this.textarea.scrollHeight / this.textarea.clientHeight;
}
}