1. 程式人生 > 其它 >解決vue+ts中報錯:Cannot read property ‘push‘ of undefined

解決vue+ts中報錯:Cannot read property ‘push‘ of undefined

網路回話:通俗講是網路引數配置的清單,可以根據不同的使用環境切換網路引數配置。

以下實驗使用一臺虛擬機器完成,PC1主機名:

1、檢視網絡卡資訊

[root@PC1 ~]# nmcli connection show
NAME         UUID                                  TYPE            DEVICE      
eno16777728  d6f581bd-b571-43bf-bb9c-c37d935855ee  802-3-ethernet  eno16777728 

2、檢視當前網路的詳細資訊

[root@PC1 ~]# nmcli connection show eno16777728
connection.id:                          eno16777728
connection.uuid: d6f581bd
-b571-43bf-bb9c-c37d935855ee connection.interface-name: -- connection.type: 802-3-ethernet connection.autoconnect: yes connection.timestamp: 1608343787 connection.read-only: no connection.permissions: connection.zone:
-- connection.master: -- connection.slave-type: -- connection.secondaries: connection.gateway-ping-timeout: 0 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 802-3-ethernet.duplex: -- 802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: 00:0C:29:66:37:F7 802-3-ethernet.cloned-mac-address: -- 802-3-ethernet.mac-address-blacklist: 802-3-ethernet.mtu: auto 802-3-ethernet.s390-subchannels: 802-3-ethernet.s390-nettype: -- 802-3-ethernet.s390-options: ipv4.method: manual ipv4.dns: ipv4.dns-search: ipv4.addresses: { ip = 192.168.10.10/24, gw = 0.0.0.0 } ipv4.routes: ipv4.ignore-auto-routes: no ipv4.ignore-auto-dns: no ipv4.dhcp-client-id: -- ipv4.dhcp-send-hostname: yes ipv4.dhcp-hostname: -- ipv4.never-default: no ipv4.may-fail: yes ipv6.method: auto ipv6.dns: ipv6.dns-search: ipv6.addresses: ipv6.routes: ipv6.ignore-auto-routes: no ipv6.ignore-auto-dns: no ipv6.never-default: no ipv6.may-fail: yes ipv6.ip6-privacy: -1 (unknown) ipv6.dhcp-hostname: -- GENERAL.NAME: eno16777728 GENERAL.UUID: d6f581bd-b571-43bf-bb9c-c37d935855ee GENERAL.DEVICES: eno16777728 GENERAL.STATE: activated GENERAL.DEFAULT: no GENERAL.DEFAULT6: no GENERAL.VPN: no GENERAL.ZONE: -- GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/2 GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/0 GENERAL.SPEC-OBJECT: -- GENERAL.MASTER-PATH: -- IP4.ADDRESS[1]: ip = 192.168.10.10/24, gw = 0.0.0.0 IP6.ADDRESS[1]: ip = fe80::20c:29ff:fe66:37f7/64, gw = ::

3、分別建立公司和家庭應用場景的網路回話

[root@PC1 ~]# nmcli connection add con-name company ifname eno16777728 autoconnect no type ethernet ip4 192.168.10.111/24 gw4 192.168.10.1   ## 建立公司的網路會話,指定IP
Connection 'company' (fcfca9d7-a794-4e0c-b14c-6465de8e96c1) successfully added.
[root@PC1 ~]# nmcli connection add con-name house type ethernet ifname eno16777728    ##建立家庭網路會話,DHCP分配IP
Connection 'house' (be7d3869-bb1c-4938-ab69-84fc89dfd6be) successfully added.

4、檢視設定的網路會話

[root@PC1 ~]# nmcli connection show
NAME         UUID                                  TYPE            DEVICE      
house        be7d3869-bb1c-4938-ab69-84fc89dfd6be  802-3-ethernet  --          
company      fcfca9d7-a794-4e0c-b14c-6465de8e96c1  802-3-ethernet  --          
eno16777728  d6f581bd-b571-43bf-bb9c-c37d935855ee  802-3-ethernet  eno16777728 

5、網路連線模式設定為橋接模式

6、 再次檢視當前IP

[root@PC1 ~]# ifconfig |  head -n 5
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.10  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::20c:29ff:fe66:37f7  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:66:37:f7  txqueuelen 1000  (Ethernet)
        RX packets 150  bytes 22145 (21.6 KiB)

7、切換至家庭網路會話,並檢查IP

[root@PC1 ~]# nmcli connection up house   ## 切換網路會話
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
[root@PC1 ~]# ifconfig | head -n 5    ## 檢視IP(DHCP自動分配)
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.19  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::20c:29ff:fe66:37f7  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:66:37:f7  txqueuelen 1000  (Ethernet)
        RX packets 174  bytes 25168 (24.5 KiB)

8、切換至公司網路會話,並檢視IP

[root@PC1 ~]# nmcli connection up company  ## 切換
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@PC1 ~]# ifconfig | head -n 5  ## 檢視IP
eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.111  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::20c:29ff:fe66:37f7  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:66:37:f7  txqueuelen 1000  (Ethernet)
        RX packets 196  bytes 26698 (26.0 KiB)

以上實驗實現了建立兩個不同的網路會話,並進行了切換驗證