2017-02-20 5 views
0

OneSignal sdkでいくつかのことを設定する。基本的には、私の通知を購読している人にのみ、コンテンツの一部を表示させたいと思っています。チュートリアルセクションのコードをコピーしました。 1つのアクションだけが必要な場合は、すべて正常に動作します。すぐに、私が別のものを追加すると、私は壊れます。ここで js if文に複数の結果を追加する

は条件が multiple statements.So条件が実行された後、それが唯一の文をproperly.Otherwise {}を閉じる必要が含まれてい

OneSignal.isPushNotificationsEnabled(function(isEnabled) { 
    if (isEnabled) 
     document.getElementsByClassName('testsig')[0].style.display = 'block'; 
     //as soon as I add following line, it stops working 
     document.getElementsByClassName('testhide')[0].style.display = 'none'; 
    else 
     console.log("Push notifications are not enabled yet.");  
    }); 
+1

複数のステートメントを囲むには、 '{}'を使用する必要があります。 – Pointy

答えて

0

ifコードの一部です。

OneSignal.isPushNotificationsEnabled(function(isEnabled) { 
    if (isEnabled) { 
     document.getElementsByClassName('testsig')[0].style.display = 'block'; 
     //as soon as I add following line, it stops working 
     document.getElementsByClassName('testhide')[0].style.display = 'none'; 
      } 
    else 
     console.log("Push notifications are not enabled yet.");  
    }); 
+0

完璧!ありがとう! – Arlindo

+0

@Arlindo助けてうれしいです。あなたがそれを解決すれば答えを受け入れてください。 –

関連する問題