【问题标题】:Angular2-App user-input changes in input-field changes input-fields in other browser-instances on other machinesAngular2-App 输入字段中的用户输入更改更改其他机器上其他浏览器实例中的输入字段
【发布时间】:2017-06-09 08:50:23
【问题描述】:

在本地主机上运行的 Angular2-App 的浏览器中编辑输入字段,更改在其他机器(平板电脑/智能手机)上运行的所有其他浏览器中输入字段的值

每个设备是否应该在其浏览器中拥有自己的 Angular-Application 实例,并且不会相互干扰?

工作流程

  1. 我在 localhost(ip: 192.168.111.1:3000) 上使用“npm start”启动 Angular2App
  2. 我使用带有http://localhost:3000 的浏览器从同一台机器连接
  3. 我使用 http:/192.168.111.1:3000 从另一台设备(例如平板电脑、智能手机)连接到 Angular2App
  4. 输入字段在所有设备上的所有浏览器中均正确显示
  5. 然而在本地主机上运行的浏览器中编辑输入字段更改所有其他输入字段的值在平板电脑/智能手机上运行的浏览器

代码sn-ps:

login.component.ts

import {Component} from '@angular/core';

@Component({
  templateUrl: 'app/components/login/login.component.html',
  selector: 'login-comp'
    ,providers: []
    ,directives: []
})

export class LoginComponent {
  private userName: String;
  private userPw: String;
...

login.component.html

<div>
    <p>User: <input pInputText id="userName" (ngModel)="userName" /></p>
    <p>Password: <input pInputText id="userPw" (ngModel)="userPw" type="password"/></p>
    <p><button (click)="login()">login</button></p>
</div>

【问题讨论】:

    标签: angular


    【解决方案1】:

    这是因为您安装了“浏览器同步”。 要禁用此功能,您必须将 Node_modules\browser-sync\lib\default-config.js 设置为 false。

    ghostMode: {
        clicks: false,
        scroll: false,
        location: false,
        forms: {
            submit: false,
            inputs: false,
            toggles: false
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-07-20
      • 1970-01-01
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多